Hi, for my game i require players appearance to be randomised on respawn. I have 4 different characters for my game to choose from. So far i have this:
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
local Characters = game:GetService("ReplicatedStorage").Players:GetChildren()[math.random(1,4)]
print(Characters)
if game:GetService("StarterPlayer"):FindFirstChild("StarterCharacter") then
game:GetService("StarterPlayer").StarterCharacter:Destroy()
end
Characters.Name = "StarterCharacter"
Characters.Parent = game:GetService("StarterPlayer")
end)
end)
Now this works, but not very accurate. Heres what happens in a nutshell.
- Spawning (As my own avatar, SHOULD spawn as one of the 4 characters)
- Reset
- Spawn as ONE of the characters
- Reset
- Spawn as my Own avatar again.
What i want from this script is so that it will ALWAYS spawn as one of the 4 characters. Please help, Thanks :)

10 comments
And to do this i will need to add an OnDied function?
I've already posted the solution. OnDied is not a existing event. Though, having the character removed is not the same as having 0 health in your humanoid (dead). So, uh, you should use CharacterRemoving.
Ok thanks, it works better now. However, How would i randomise the character so that on spawn the player has one of the randomised characters, because at the moment the player still spawns as him/herself as soon the play button is pressed
Edited, try it out.
Brilliant, Thankyou
Now you have corrected it i can now understand the logic, quite a simple fix all along :P. Thankyou so much.
No problem
Can I use this script for my own game?
Also, where do you put the script/localscript ?
The Server Script Service i think