Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago

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

0
Have you tried placing the FireClient after freezing the character in Server Script? T3_MasterGamer 2189 — 2y

1 answer

Log in to vote
0
Answered by
SuperPuiu 497 Moderation Voter
2 years ago

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.

Ad

Answer this question