Broken Character Script Needs Fixing

Someone gave me a script that I can use so when a player joins, they get teleported to the lobby they become a custom character, here is the script:

local teams = game:GetService("Teams")
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)

		local character = char
		if player.Team == teams["Lobby"] then
			local character = game.ReplicatedStorage.Default:Clone()
			character.Name = player.Name
			player.Character = character
			character.Parent = workspace
		end	
	end)
end)

The issue is that whenever the script replicates the character, the character keeps continuously getting teleported back to were the model of the custom character was.

How can I fix this?

local teams = game:GetService("Teams")
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(char)
		if player.Team == teams["Lobby"] then
            char.Archivable = true
			local clone = char:Clone()
            clone:WaitForChild("HumanoidRootPart").Anchored = true
			local character = game.ReplicatedStorage.Default:Clone()
			character.Name = player.Name
			player.Character = character
			character.Parent = workspace
			character:WaitForChild("HumanoidRootPart").CFrame = CFrame.new(clone:WaitForChild("HumanoidRootPart").Position)
			clone:Destroy()
		end	
	end)
end)
1 Like

Its spawned MULTIPLE Clones of me