I’m trying to make simple main menu script, but it don’t work. I think the RemoteEvent.OnClientEvent is broken. I tried to fire it from the server script located inside ServerScriptService and print something like "A", but nothing happen. Idk what else to do now. Please help me fix it.
LocalScript(MenuClient)
ModuleScript(Player)
Output:
I posted about this yesterday and ended with me giving up and decided to rewrite the scripts… and still didn’t work.
You said that the server code that you provided was in a ModuleScript, correct? Because if the server code you provided is in a Module script just like that, it won’t work. You need that server code in a regular script, then it should work. That worked for me.
I Believe the issue is caused by the Player:LoadCharacter() which destroys the local script, here is the setup:
Simple setup,
local event = game.ReplicatedStorage.RemoteEvent
game.Players.PlayerAdded:Connect(function(player)
print("Server")
print(player)
event:FireClient(player,"Test","Hello1234")
player:LoadCharacter()
end)
Local script in starterGUI
local event = game.ReplicatedStorage.RemoteEvent
print("Local")
event.OnClientEvent:Connect(function(...)
print(...)
end)
then the prints:
Notice how it prints what the remote event is sending once, however the second time it stops, because the message was only sent once towards the GUI that was destroyed because the player reset by player:LoadCharacter
Anyways if you want the menu to load only once upon player added why not just store a BoolValue or attribute within the local player?
Actually, module scripts inherit the context level of the script that originally required them. Meaning a module in replicated storage being required by a local script will be instantiated and run locally. Similarly, if a server script requires the same module, it will run that module on the server side.