Require special currency to teleport

What he just said is basic scripting knowledge, if you dont know that much please dont ask for help. Nobody will be able to help if you cant help yourself.

local touchPart = script.Parent
--You need a leaderstats for the currency and for this script to work properly...

touchPart.Touched:Connect(function(hit)
   local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)
   local currency = player.leaderstats.coins

   if currency >= 100 then
     print("Yay, enough coins!")
     --do whatever if player has more than or equal to 100 coins(optional
   else
     print("Player doesn't have enough coins")
     --If not then do what ever here..
   end
end)

Basically use this script, you will understand it eventually as you look at it

the thing is once i have it i get how it works

so it needs to be like this

In the currency variable itā€™s referring to coins so you can just change that up as it was an example I madeā€¦

Why do you post screenshots when I told you to post it as text here formatted by ``` surrounding the block of code. If you expect people to help, you should follow forum etiquette. Posting screenshots is a pain because you may need multiple screenshots to cover the entire script while posting it as text prevents that and also makes it easier to read. We also can then quote it and add things to it to fix it. This will be my last message about it and Iā€™m sorry if Iā€™m sounding like a mini boss but everyone else doesnā€™t post screenshots of code in this forum.

1 Like

oke i will do that from now on

@rohanspeeltgames Watch this tutorial video if you are still unsureā€¦
The tutorial video uses a click event for the part instead of touchā€¦other than that it makes sense and will most likely help you!

https://www.youtube.com/watch?v=2fX5DRjLMuQ

but how do i get the script for money that starts with 1 to 0

i think i need to remake the full leaderstats script

Are you a beginner at scripting on roblox?
I suggest you watch some youtube tutorials and read the developer documentation pageā€¦

okay thanks but i am on a time limit

i have 16 hours to fix the leaderstats and make the teleporter work

In your script you called p instead of the player variable I madeā€¦
image

i changed it to player but the script still does not work

can the currency be lower than 100 on the script

The amount of currency required to teleport the player can be changed, it is obivous by now that you could easily change it to a different value.

You might wanna do some research to questions you are wondering and ask after being unable to solve it through research or tutorialsā€¦

this is the script i have now the arnt any mistakes right
local Teleport_To_This_Tag = ā€œ0004ā€ ā€“ This is the Tag thing you find in the teleporter bricks. The brick with the tag that matches this is the brick you will tele to once you touch this one.

function findTele(tag)
local tele = nil
function scan(p)
for _,v in pairs(p:GetChildren()) do
if ((v.Name == ā€œTelepadā€) and (v:findFirstChild(ā€œTagā€))) then
if (v.Tag.Value == tag) then tele = v break end
end
if (#v:GetChildren() > 0) then scan(v) end
end
end
scan(game:service(ā€œWorkspaceā€))
return tele
end

script.Parent.Touched:connect(function(h)
local touchPart = script.Parent
ā€“You need a leaderstats for the currency and for this script to work properlyā€¦

touchPart.Touched:Connect(function(hit)
local player = game:GetService(ā€œPlayersā€):GetPlayerFromCharacter(hit.Parent)
local currency = player.leaderstats.Multi

if currency >= 1 then
ā€“do whatever if player has more than or equal to 100 coins(optional
player.Character:MoveTo(tele.CFrame.player+Vector3.new(0,0,0))
local t = Instance.new(ā€œWeldā€)
t.Name = ā€œJustTeleportedā€
t.Parent = player
delay(1.5,function() t:remove() end)
end
end)

If itā€™s really that hard for you, I will create a game of it which you are able to editā€¦
Give me 10-15 minsā€¦