Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't this remote event, which communicates from server to client, working properly?

I have a remote event going from a server to a client. It doesn't seem to work as I don't receive any output from the print function on the local script.

This is the server script.

ReplicatedStorage = game.ReplicatedStorage
dialogEvent = ReplicatedStorage.dialogEvent

dialogEvent:FireAllClients()

This is the local script.

ReplicatedStorage = game.ReplicatedStorage
dialogEvent = ReplicatedStorage.dialogEvent
 
function onDialogEventFired()
	print("finally")
end
 
dialogEvent.OnClientEvent:Connect(onDialogEventFired)

1 comment

0

You may have to do ReplicatedStorage:WaitForChild("dialogEvent")

1 answer

✓ Accepted answer

Likely isn't working because not everything in the game hasn't loaded in yet. I added GetService on ReplicatedStorage, and a WaitForChild for the event itself just to make sure they loaded in, also added a wait() right before firing the event and it worked.

Server Code:

ReplicatedStorage = game:GetService("ReplicatedStorage")
dialogEvent = ReplicatedStorage:WaitForChild("dialogEvent")
wait()
dialogEvent:FireAllClients()

Client Code:

ReplicatedStorage = game:GetService("ReplicatedStorage")
dialogEvent = ReplicatedStorage:WaitForChild("dialogEvent")

function onDialogEventFired()
    print("finally")
end

dialogEvent.OnClientEvent:Connect(onDialogEventFired)

The things I added shouldn't delay the code enough to mess anything important up.

1 comment

0

Brill! Thank you, really appreciate the response!

This discussion is preserved as it was. New answers, comments, and votes are closed.