Question is in the title. I'm having trouble getting this code to fire each time the character spawns.
local remoteEvent = game.ReplicatedStorage.RemoteEvent local function onCharacterAdded(character) print("1") remoteEvent:FireClient(character) end Players.PlayerAdded:Connect(onCharacterAdded)
I feel like I'm most likely making a stupid mistake, but any help would be appreciated.
The error is that you're using the function when the Player
is joining the game, not the Character
spawning.
For what you're asking, we will be using the CharacterAdded
event with the player.
Here's the revised code:
local remoteEvent = game.ReplicatedStorage.RemoteEvent game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) remoteEvent:FireClient(character) end) end)
This should (in theory) work out for you, if you have any questions or concerns, feel free to post such in the comments and we can work it out!