Hello, Thanks for your coming. What I am trying to do is a test for remote event, here is my script:
Script:
game.Players.PlayerAdded:Connect(function(player) Instance.new(“RemoteEvent”,game.ReplicatedStorage).Name = “message” Instance.new(“RemoteEvent”,game.ReplicatedStorage).Name = “answer” game.ReplicatedStorage.message:FireClient(player,“test”) --Mark 1 game.RpelicatedStorage.answer.OnServerEvent:Connect(function(data) print(data) end) end)
Local Script:
game.ReplicatedStorage.message.OnClientEvent:Connect(function(data) game.ReplicatedStorage.answer:FireServer(data) end)
from my exception and inference, the output should be what I put after player at mark 1, but actually it does nothing at all, so what is the error? If you know then please answer me. Thanks!
Client is not yet loaded, PlayerAdded
fires when you enter the game which is long time before your local scripts actually run, that way when on line 4 you fire the event, your local script is not receiving it as it yet did not run so it did not connect the function, i have answered same answer here.
From what I can see, your problems are:
1.The parameters of OnServerEvent is player and arguments or the data passed through the FireServer()
2.You spelled your ReplicatedServer wrong.
So use this instead:
game.ReplicatedStorage.answer.OnServerEvent:Connect(function(player, data) print(data) end)