i try to make a teleport system but i got an error
game.Workspace.Pulau1:WaitForChild("P1")
local Teleport = "P1"
local rc = 2
local debounce = true
function Touch(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local leaderstats = player.leaderstats
if leaderstats.Kepintaran.Value >= rc then
if debounce then
debounce = false
if script.Parent.Locked == false and script.Parent.Parent.Parent.Pulau1:FindFirstChild(Teleport).Locked == false then
script.Parent.Locked = true
script.Parent.Parent.Parent.Pulau1:FindFirstChild(Teleport).Locked = true
local Pos = script.Parent.Parent.Parent.Pulau1:FindFirstChild(Teleport)
hit.Parent.CFrame = CFrame.new(Vector3.new(Pos.Position))
wait(1)
script.Parent.Locked = false
script.Parent.Parent.Parent.Pulau1:FindFirstChild(Teleport).Locked = false
end
end
debounce = false
end
end
script.Parent.Touched:Connect(Touch)
it says, try to index nil with 'leaderstats'

4 comments
Player doesn't exist
You have to make sure the colliding part is part of a player character
how
put this at the top: local player = game:GetService("Players")