hi, i made a teleport script but i need to make sure that it only works if you have a certain amount of currency or more. the name of the currency is PowerBlocks
here is the script
script.Parent.Touched:connect(function(hit) if hit.Parent:FindFirstChild('Humanoid') then if hit.leaderboard.PowerBlocks.Value >= 2 then hit.Parent.Head.CFrame = CFrame.new(-80, 15.5, 7) end end end)
let me know if you find anything wrong with this script. thanks in advance from poopypigeon245
The variable that you called hit is not the player instance but rather the body part of the character that touches the part. To get the player, you can use the :GetPlayerFromCharacter() function. As well as this, the leaderboard information should be stored inside something called leaderstats not leaderboard.
script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr and plr.leaderstats.PowerBlocks.Value >= 2 then hit.Parent.HumanoidRootPart.CFrame = CFrame.new(-80,15.5,7) end end end)
is there a leaderboard in your Humanoid?
If not, define player.
script.Parent.Touched:connect(function(hit) player = game.Players:GetPlayerFromCharacter(hit.Parent) character = hit.Parent if player and player:IsA("Player") then -- to check if it is a player and if the player exists if player.leaderboard.PowerBlocks.Value >= 2 then -- i corrected, assuming that 'leaderboard' is in player character.Head.CFrame = CFrame.new(-80, 15.5, 7) -- not sure why are you only positioning the head end end end)