Hello, I have a scripting question. So I have it so there is a Text Button inside of a frame, inside of a Screen Gui, inside of Starter Gui. So basically I want the textbutton to teleport you to a specific part, but I also want it to make it so it checks if you have a specific amount of points and take that amount away from you, like basically paying for it. I want to make it so when you click that text button, you are required to pay 1000 points (from leaderstats) and if you have it, they take those 1000 points away (like paying in a shop) and in exchange, teleport you to a specific part/position. I am aware that the text button has to be the same name as the name of the part for it to teleport to that part, by the way. I ALSO HAVE A LEADERSTAT SET. THE SCRIPT WORKS AND TELEPORTS ME BUT I also want to make it so you have to pay those 1000 points. Here is my code so far to make it so the text button teleports you to a part:
wait(1)
player = game.Players.LocalPlayer
button = script.Parent
local debounce = false
function teleport()
if not debounce then
debounce = true
LowerTorso = player.Character.LowerTorso
LowerTorso.CFrame = game.Workspace.TeleportPoints.ToolsTP.CFrame
end
end
button.MouseButton1Click:Connect(teleport)
while true do wait()
debounce = false
wait(1)
end
Edit the code or rewrite to make it so it teleports you to that part by paying with points.. Also, "TeleportPoints" is the name of the folder in Workspace which leads you to the name of the part, ToolsTP.

1 comment
Any further questions, you can ask me