I'm trying to make a game, and am trying to get one script to trigger a function in another script. In the script that triggers the event there is an Events.Broadcast() and in the script with the function to trigger there is a Events.Connect() at the end of the script (after the function).
Hey @LittleBit!
You can use script.context for that, but you need to reference the other script first.
Then you can do: script.context:MyFunction()
The other way is working with broadcasts like you mentioned. You just need to care about the rate limit (usually not a problem) and in which context you want to broadcast (client - server).
Hope this helps
I think you can do this too:
in your script 1 send you the info (ClientContext) :
Events.Broadcast("Example1client")
Then you create a new script you put this in to receive :
function Example1client(player)
print("Example1clientReceive!")
end
Events.Connect("Example1client", Example1client)
If you want to do it in server I think you have to replace with this: :
-Events.BroadcastToServer("Example2server")
-Events.ConnectForPlayer("Example2server", Example2server)
API :