Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

What scripting would I use to make a tycoon button and to check if you have enough money? [closed]

Asked by 3 years ago

Just wanting to know how I can make a tycoon button or circle to build the item its meant to build and how to get it to read the amount of money needed to be spent on that build.

Closed as Not Constructive by Shounak123 and DeceptiveCaster

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
3 years ago
Edited 3 years ago

You can detect the player's money value, if it's higher than the requirement, set the money value to money value minus the price.

Heres an example. You must use LocalScript for this! Make sure you put the script in StarterGui.

script.Parent = game:GetService("StarterGui") -- For safety purposes, I set it to you

local button = game.Workspace.Button1
local requirementmoney = 100

button.Touched:Connect(function()
    if game:GetService("Players").LocalPlayer:WaitForChild("leaderstats").Money.Value > requirementmoney - 1 then
        game:GetService("Players").LocalPlayer:WaitForChild("leaderstats").Money.Value = game:GetService("Players").LocalPlayer:WaitForChild("leaderstats").Money.Value - requirementmoney
        button:Destroy()
    else
        print("Not enough money! ".. requirementmoney - game:GetService("Players").LocalPlayer:WaitForChild("leaderstats").Money.Value  .." money is needed to purchase."
    end
end)

This is just an example, the Instances and Values' locations are needed to set on your own.

NOTE: Not all LocalScript will work in workspace.

0
If you really wanna use a Localscript to set the Money of the User you're either a Noob or outdated by 4 Years. DindinYT37 246 — 3y
0
What do you mean? I think I meant like he said? So what do you need then. Xapelize 2658 — 3y
0
You also can use a script, but I wouldn't recommend. My way works either if there's no errors... Xapelize 2658 — 3y
Ad