Hello, devs!
I've created a script that when a player joins with a specific name then they get a specific character. Else if they don't have any of the specified names then they spawn as a different character.
The script works fine until you rejoin. Whenever you rejoin the script no longer seems to work. I can't seem to figure out why.
Here is my current script:
local value = 0
game.Players.PlayerAdded:connect(function(plr)
value = 0
end)
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:connect(function(char)
wait(1)
if plr.Name == "NAME" and value == 0 then -- specific player character switcher
local model = game.ReplicatedStorage.King.StarterCharacter
local model1 = model:Clone()
model1.Parent = game.Workspace
model1.PrimaryPart.CFrame = plr.Character.PrimaryPart.CFrame
plr.Character = model1
model1.Humanoid.HipHeight = 3.8
value = 1
else if plr.Name == "NAME" and value == 0 then -- specific player character switcher
local model = game.ReplicatedStorage.Dev.StarterCharacter
local model2 = model:Clone()
model2.Parent = game.Workspace
model2.PrimaryPart.CFrame = plr.Character.PrimaryPart.CFrame
plr.Character = model2
model2.Humanoid.HipHeight = 3.8
value = 1
else if value == 0 then -- Normal player character switcher
local model8 =
game.ReplicatedStorage.NormalPlayers.StarterCharacter
local model14 = model8:Clone()
model14.Parent = game.Workspace
model14.PrimaryPart.
CFrame = plr.Character.PrimaryPart.CFrame
plr.Character = model14
model14.Humanoid.HipHeight = 3.8
value = 1
end
end
end
end)
end)
If anyone could please help me, or point me in the right direction that would be greatly appreciated!
