game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) wait(0.1) script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then hit.Parent.HumanoidRootPart.CFrame = game.Workspace:FindFirstChild(tostring(player.leaderstats.Stage.Value)).CC.CFrame end end) end) end)
this for some reason makes every player teleport to the stage i am at when dying and touching one of these parts with this script in it ^^
Please help!
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("HumanoidRootPart") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) hit.Parent.HumanoidRootPart.CFrame = CFrame.new(game.Workspace:FindFirstChild(tostring(player.leaderstats.Stage.Value)).CC.Position) end end)
this will get the player from the touch (never use the characteradded function when you want the player who touched it) and teleports them to the place they should be on
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(character) wait(0.1) script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if hit.Parent.Name == character.Name then hit.Parent.HumanoidRootPart.CFrame = game.Workspace:FindFirstChild(tostring(player.leaderstats.Stage.Value)).CC.CFrame end end end) end) end)
This should work, the problem with your script was that it wasent checking who touched it, because that touched event is running for everyone. instead you have to check if the person that wants to teleport was the person that actually touched it.