My problem is when a player touch the part it automaticly teleport every players at the 'Respawn' Part,
I just want to teleport the player who touch it
local amount = 250
debounce = true
script.Parent.Touched:Connect(function(hit)
local player = game.Workspace[hit.Parent]
print(player.Name)
if player.Character then
local stats = player:FindFirstChild("leaderstats")
if stats then
local gui = player.PlayerGui
if gui then
if debounce == true then
debounce = false
stats.Cash.Value = stats.Cash.Value +amount
game.Workspace.TrainingMap.EndLavaMap.Sound:Play()
player.Character:MoveTo(workspace.Respawn.Position)
gui.PlayerFrame.Menu.AddRemove.Text = "+"
wait(1)
gui.PlayerFrame.Menu.AddRemove.Text = ""
debounce = true
end
end
end
end
end)

1 comment
A) MoveTo() and CFrame do exactly the same thing B) it is actually better to get the player from their model in Workspace as opposed to within the Players service C) his character line can simply be 'if player then' since 'player' is the model