I want the startercharacter to be randomized every time the player respawns.
No console errors, just doesn’t work.
Here’s my code (it is in StarterPlayerScripts):
game.Players.PlayerAdded:connect(function(plr)
local Characters = game:GetService("ReplicatedStorage").Players:GetChildren()[math.random(1,3)]
if game:GetService("StarterPlayer"):FindFirstChild("StarterCharacter") then
game:GetService("StarterPlayer").StarterCharacter:Destroy()
end
Characters.Name = "StarterCharacter"
Characters.Parent = game:GetService("StarterPlayer")
plr.CharacterRemoving:connect(function(char)
Characters = game:GetService("ReplicatedStorage").Players:GetChildren()[math.random(1,3)]
if game:GetService("StarterPlayer"):FindFirstChild("StarterCharacter") then
game:GetService("StarterPlayer").StarterCharacter:Destroy()
end
Characters.Name = "StarterCharacter"
Characters.Parent = game:GetService("StarterPlayer")
end)
end)
game.Players.PlayerAdded:connect(function(plr)
local character = plr.CharacterAdded:Wait()
local Character = game:GetService("ReplicatedStorage").Players:GetChildren()[math.random(1,3)]:Clone()
Character.PrimaryPart.CFrame = character.PrimaryPart.CFrame
Character.Parent = workspace
plr.Character = Character
end)