Calls the remote, which I believe where the issue is.
game.Players.PlayerAdded:Connect(function() game.ReplicatedStorage.Begin:FireServer() end)
This is what the RemoteEvent executes.
game.ReplicatedStorage.Begin.OnServerEvent(function() print('Hello') end)
I get this should be a simple fix, but I don't get why it is not executing correctly.
Could you try to use this function and tell me how it works?
game.Players.PlayerAdded:Connect(function(plr) -- Remote Event end)
I believe what is happening is that the player joins before the event loads in. If this is the case, use WaitForChild()
to wait for the event to load in:
Local Script
local event = game:GetService("ReplicatedStorage"):WaitForChild("Begin") -- This is the remote event game.Players.PlayerAdded:Connect(function() event:FireServer() end)
Server Script
game:GetService("ReplicatedStorage"):WaitForChild("Begin").OnServerEvent:Connect(function() print("Hello") end)
You should always use WaitForChild()
to wait for something to load, especially a RemoteEvent
. Players tend to be one of the first things to load in, and sometimes they load in before other Instances.