How do i make that when player teleport his stage stats return to 1.
the teleport is working but the stage value not changing .
script:
local Pad2 = game.Workspace.Teleport3
local Players = game:GetService("Players")
script.Parent.Touched:Connect(function(touchPart, player)
if touchPart and touchPart.Parent and touchPart.Parent.Humanoid and touchPart.Parent.currentlyTeleporting.Value == false then
local Character = touchPart.Parent
local teleportLocation = CFrame.new(Pad2.CFrame.X, Pad2.CFrame.Y + 5, Pad2.CFrame.Z)
Character:SetPrimaryPartCFrame(teleportLocation)
player.leaderstats.Stage.Value = 1
local teleportingValue = Character.currentlyTeleporting
teleportingValue.Value = true
wait(3)
teleportingValue.Value = false
end
end)
this part is not working: player.leaderstats.Stage.Value = 1
I’m not entirely sure that player is identified with a touch…
Perhaps do this instead:
local player = game:GetService("Players"):GetPlayerFromCharacter(Character) -- You already identified the Character. (touchPart.Parent)
if (player) then
-- do stuff/player.leaderstats.Stage.Value = 1
end
local Pad2 = game.Workspace.Teleport3
local Players = game:GetService("Players")
script.Parent.Touched:Connect(function(touchPart)
if touchPart and touchPart.Parent and touchPart.Parent.Humanoid and touchPart.Parent.currentlyTeleporting.Value == false then
local Character = touchPart.Parent
local player = game:GetService("Players"):GetPlayerFromCharacter(Character) -- You already identified the Character. (touchPart.Parent)
local teleportLocation = CFrame.new(Pad2.CFrame.X, Pad2.CFrame.Y + 5, Pad2.CFrame.Z)
Character:SetPrimaryPartCFrame(teleportLocation)
if (player) then
-- do stuff/player.leaderstats.Stage.Value = 1
end
local teleportingValue = Character.currentlyTeleporting
teleportingValue.Value = true
wait(3)
teleportingValue.Value = false
end
end)
Like this is fine, just add the variables and clean up a bit so you’re not lost.