I'm trying to make a teleport button that only lets you teleport if you have a certain amount of money on the leader board but there's an error on line 7 Player isnt a valid value, any help?
Here's my script:
function onClicked() local p = game.Players:GetChildren() for i = 1, #p do
if player.leaderstats.Money.Value > 1 then --player in this line wasnt valid, can someone explain why? im still new
end h.Parent.Torso.CFrame = CFrame.new(Vector3.new(281, 30.6, -26))
end end end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
"player" is not defined. Make it a value by doing:
local player = --or player =
for
loop.ClickDetector.MouseClick
event passes the player as a parameter, so this makes it easy.-- Server Script inside part script.Parent.ClickDetector.MouseClick:Connect(function(plr) if plr.leaderstats.Money.Value > 1 then plr.Character.HumanoidRootPart.CFrame = CFrame.new(281, 30.6, -26) end end)