I created a map changing script and each time the map changes i want an event to fire to another serverscript so coins can spawn in that new map, how can i do this?
however i suggest you just do it in the same script
Use a BindableEvent
. You can send a request by using the :Fire()
function (equivalent of :FireServer() or :FireClient()), and connect an event to it by using the .Event
(equivalent of .OnServerEvent or .OnClientEvent) event.
You can use a BindableEvent instance, like so:
Your map script:
local bindableEvent = game.ServerStorage.BindableEvent -- path to your event
-- [[ Fire the event whenever the map changes ]]
bindableEvent:Fire(mapName) -- You can use mapName to identify which map to spawn coins in.
Your coin script:
local bindableEvent = game.ServerStorage.BindableEvent
bindableEvent.Event:Connect(function(mapName)
print("Let's spawn coins in a map called " .. mapName)
end)
i tried the bindable event but it doesnt seem to come through since i used prints and it only printed the bindable event being sent but not the server responding to it
this the server script sending the bindable event
this is the server script responding to it
this is what came out only

this is where the bindable event is located

is there something i did wrong?
why exactly do you have an event inside of a while loop
Try removing the loop in the server script responding to it, you only need to connect an event once for it to always listen.
Putting it in an infinite loop creates a memory leak, as it will connect multiple times.
i’m assuming op wanted the CoinEvent to have a cooldown (16 seconds)
This script isn’t working because your connecting the event AFTER the cooldown in the script that is responding. a Better way to do this is being putting that while loop in the other script and sending the signal to run the coin event from there.
Script one says once this cool down ends, fire this bindable event
Script two says when I get signal the the event has been fired, do this function
could you tell me why you have a loop here?
while task.wait(cooldown) do
coinevent.Event:Connect(…
Thats my mistake, i forgot to remove it when adding the bindable event since before finding out about bindable events, i used a while loop for the script, i removed it and the script works now
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.