So I have been getting this error called "Unable to cast value to Object" on this script and it says the error is on Line 3 of the server script, mind if you can look over it and see if it can be fixed or maybe some changes? NOTE: A RemoteEvent is in ReplicatedStorage called, "ServerMessageEvent".
SERVER SCRIPT:
game.Players.PlayerAdded:Connect(function(player) wait(0.5) game.ReplicatedStorage.SystemMessageEvent:FireClient("[Server]: "..player.Name.." has joined the game!") end)
LOCALSCRIPT:
game.ReplicatedStorage.SystemMessageEvent.OnClientEvent:Connect(function(message) game.StarterGui:SetCore("ChatMakeSystemMessage", { Text = message; Color = BrickColor.new("New Yeller").Color; Font = Enum.Font.Garamond; FontSize = Enum.FontSize.Size18; }) end)
RemoteEvents require at least one argument when calling FireClient()
, which is the player. In your script, you're not firing the RemoteEvent to any client, just the string. To fix this, simply add the player that joined as the first argument
game.Players.PlayerAdded:Connect(function(player) wait(0.5) game.ReplicatedStorage.SystemMessageEvent:FireAllClients("[Server]: "..player.Name.." has joined the game!") end)
edit: missed FireAllClients() somehow
creeper did a good job explaining the issue, but that's not the full answer. You need to make a loop to fire the remote event to every player, just so it goes to all players.