Firstly, I'd suggest making an end part (a part that the player will teleport to)
Secondly, the Humanoid is in a player's Character, not in the Player itself!
Thirdly, you're picking up the "plr" completely out of the blue. You have to get the player, not just magically reference it!
Here's the fixed code for ya:
local endpart = game.Workspace:WaitForChild('endteleport')
local startpart = script.Parent
local coinsneeded = 100
startpart.Touched:Connect(function(touched)
local char = touched.Parent
local plr = game.Players:GetPlayerFromCharacter(char)
local coins = plr.leaderstats.Coins.Value
local humroot = char.HumanoidRootPart
if coins >= coinsneeded then
humroot.Position = endpart.Position
print('Teleported '..plr.Name' successfully!')
else if coins < coinsneeded then
print(plr.Name..' does not have enough coins to enter the teleporter!')
end
end
end)
1 comment
HumanoidRootPart > Torso; also, plr refers to the Humanoid, you should realisticly use plr.Parent