I am making a game for my group, and my local script is not receiving a fired client event from a server script. I developed it in a private game, and then was going to switch it over to the group-owned game when I ran into the issue.
The ServerScript (in ServerScriptService) looks like this,
game.Players.PlayerAdded:Connect(function(Player) print("Player joined.") MainMenuEvent:FireClient(Player, "Joined") print("Fired join event.") local Character = game.Workspace:WaitForChild(Player.Name) Character.Humanoid.WalkSpeed = 0 end)
The LocalScript (in StarterGUI) looks like this,
MainMenuEvent.OnClientEvent:Connect(function(Status) print("Received") if Status == "Joined" then print("Joined") Initialize() MenuCam() script.Parent.MenuMusic:Play() end end)
it is supposed to open up a menu while also freezing the character, however, it only freezes the character and doesn't open the menu. The server prints that it fired but the local script never prints that it received, the menu doesn't open. The strangest part about this is that it only doesn't work in a group-owned game! It works perfectly in a private game but as soon as I upload the EXACT SAME GAME to a group place, it breaks! I promise you I triple checked to see that nothing was interfering, the games are identical except that the broken one is owned by my group. please help :(
You have to change this:
game.Players.PlayerAdded:Connect(function(Player) print("Player joined.") MainMenuEvent:FireClient(Player, "Joined") print("Fired join event.") local Character = game.Workspace:WaitForChild(Player.Name) Character.Humanoid.WalkSpeed = 0 end)
To this:
game.Players.PlayerAdded:Connect(function(Player) Player.CharacterAdded:Connect(function() print("Player joined.") MainMenuEvent:FireClient(Player, "Joined") print("Fired join event.") local Character = game.Workspace:WaitForChild(Player.Name) Character.Humanoid.WalkSpeed = 0 end) end)
Well, it might not work correctly, but I think you found why it isn't working. It wasn't working because PlayerGui wasn't loaded and the localscript wasn't loaded as well.