Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how do i make this teleport script only work if i have a certain amount of currency or more?

hi, i have a working teleporter script in my game but i need to make sure that it only teleports the player if they have the right amount of currency or more. but i dont want the amount of currency taken away from the player.

this is the teleport script:

script.Parent.Touched:connect(function(hit)
	if hit.Parent:FindFirstChild('Humanoid') then
		hit.Parent.Head.CFrame = CFrame.new(-165, 16.5, -42) 
	end
end)

thanks in advance from poopypigeon245

2 answers

This is really simple. All you need to do is check if the player has enough money using a simple if statement. The question is, how do you keep track of the player's money. Modify your script to something like this:

script.Parent.Touched:connect(function(hit)
    if hit.Parent:FindFirstChild('Humanoid') then
		if hit.Money.Value >= 100 then
        		hit.Parent.Head.CFrame = CFrame.new(-165, 16.5, -42)
		end
    end
end)

Replace hit.Money.Value with the amount of money the player has; make sure that this gets updated when the player gains/loses money

And that's it.

Plz accept this answer if this helped you, thanks

5 comments

0

what do you mean by 'replace hit.money.value with the amount of money the player has'?

0

well, where do you keep track of how much money a player has? How can someone find out how much money he/she has? Where is the information of how much money the player has? That's what you are supposed to replace with.

0

if hit.leaderboard("PowerBlocks") >= 2 then

0

well then yeah replace hit.Money.Value with hit.leaderboard("PowerBlocks") then if you didn't already do so

0

it still wont work. should it work if the currency is over 2?

script.Parent.Touched:connect(function(hit)

 if hit.Parent:FindFirstChild('Humanoid') then
if GetPlayerFromCharacter(hit.Parent).locationofmoney.moneyvalue>=thevalueneededtoteleport then
      hit.Parent.Head.CFrame = CFrame.new(-165, 16.5, -42)

  end
end
end)


Honestly idk if itll work but itd be something around those lines. Also typed it on my phone

This discussion is preserved as it was. New answers, comments, and votes are closed.