I am trying to make a script that requires you to buy permanent access to a teleporter can you help me please?
This is my current code below:
function touch(hit)
if game.Players:findFirstChild(hit.Parent.Name) ~= nil then
player = game.Players[hit.Parent.Name]
local Teleport = "Entered_Candy_Land" --Put the name of the Part between the ""s.
if player.Lands.CandyLandBought.Value == false then
if player.PlayerGui:findFirstChild("BuyCandyLand") == nil then
local gui = script.BuyCandyLand:clone()
gui.Parent = player.PlayerGui
repeat
wait()
until (player.Character.Torso.Position - script.Parent.Position).magnitude > 75
gui:remove()
else
if player.Lands.CandyLandBought.Value == true then
print("Bought!")
if script.Parent.Locked == false and script.Parent.Parent:findFirstChild(Teleport).Locked == false then script.Parent.Locked = true script.Parent.Parent:findFirstChild(Teleport).Locked = true --Checks Debounce.
local Pos = script.Parent.Parent:findFirstChild(Teleport) --Gets the Part to teleport to.
hit.Parent:moveTo(Pos.Position) wait(1) script.Parent.Locked = false script.Parent.Parent:findFirstChild(Teleport).Locked = false end end --Takes you there and Ends the Function.
end
end
end
end
script.Parent.Touched:connect(touch)