#When firing a RemoteEvent, can you make the original script WAIT until the event is finished?

1 messages · Page 1 of 1 (latest)

dawn quiver
#

When firing a RemoteEvent, can you make the original script WAIT until the event is finished?

marsh roost
#

Use a remote function

#

it waits for a value to be returned

dawn quiver
#

could you give me an example of how one would call the function? what I'm doing is this:

local enemyTurn = ReplicatedStorage:WaitForChild("EnemyTurn")

if enemyTurn then
  enemyTurn:FireServer()
end                ```
dawn quiver
marsh roost
#

oke

#

wait

#

This is a pretty jank way to use it but here:

--Local script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteFunction = ReplicatedStorage:WaitForChild("RemoteFunction")



print("Start")

remoteFunction:InvokeServer()

print("End")
--Will take 3 seconds
--Server script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteFunction = ReplicatedStorage.RemoteFunction


remoteFunction.OnServerInvoke = function(player)
    task.wait(3)
end
dawn quiver
marsh roost
#

yes and change the connection

#

remoteFunction.OnServerInvoke = function(player)

end

dawn quiver
#

kk, thank you!

dawn quiver
#

Workspace.Event Script Stuff.EnemyTurn:206: attempt to call a Instance value, with "player" in the parinthesis being highlighted as the error