Hello,
I'm trying to make a script that teleports the player to their current stage. The script does work, but all the methods I've tried teleports all players to their current stage. Not only the one who touched the part! How would I go about fixing this? Please help me!
This is my latest try. Help is appreciated!
local Debounce = false
function TPToCurrentStage(hit)
local Players = game.Players:GetPlayers()
for i = 1, #Players do
local plr = Players
local StageNumber = Players[hit.Parent].leaderstats.Stage.Value
local StageString = tostring(StageNumber)
if StageString == "0" then
local StageO = game.Workspace.LobbySpawns.Spawn
Players[hit.Parent.Name].Character.HumanoidRootPart.CFrame = StageO.CFrame + Vector3.new(0,3,0)
else
local CurrentStage = game.Workspace.Levels:FindFirstChild(tostring(StageString))
Players[hit.Parent.Name].Character.HumanoidRootPart.CFrame = CurrentStage.CFrame + Vector3.new(0,3,0)
end
end
end
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and Debounce == false then
Debounce = true
TPToCurrentStage(hit)
wait(.5)
end
Debounce = false
end)
