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

LocalScript not receiving client event, but only in group games?

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 :(

1 comment

0

Have you tried placing the FireClient after freezing the character in Server Script?

1 answer

✓ Accepted answer

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.

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