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

How do I make a surfacegui that gives you a specific amount of money when you click a button on it?

Asked by 3 years ago

WATCH THIS VIDEO TO UNDERSTAND BETTER: https://streamable.com/0mqgim

I'm trying to make a money printer for my game that adds 25 to a value every 2 seconds, then shows the value on a surfacegui (I got this part working, I only need help with the next problem), and a button that turns the value into money and gives you it. I spent like an hour trying to find a solution online, the devforum, youtube, developer wiki, etc. but nothing worked. All scripts and other information are shown in the video above.

2 answers

Log in to vote
0
Answered by
VitroxVox 884 Moderation Voter
3 years ago

We're here to help you with scripting error's not to make you something, but I have time and I don't see anything stopping me from helping you so here you go I've set up a little printer test / model for you get the model here

0
Works beautifully but I want any player to be able to claim the money, not just 1 specific player, I'll figure something out. ElevateTheSecond 11 — 3y
0
Well, kind of disappointed from a moderation voter, just giving up the models. At least, you could have added some explanation to your script. BestCreativeBoy 1395 — 3y
0
Well, I'm a type of guy who knows what to do. A lot of people (including me) learn from models like this, I've been in his shoes and I learned from other's projects (not from wiki's or tutorials does don't let you really learn) You really need a brain , need to learn something when you see a source. VitroxVox 884 — 3y
0
So you see this is why I rarely explain stuff, If he wants to learn he's going to learn from my source anyway. VitroxVox 884 — 3y
Ad
Log in to vote
1
Answered by 3 years ago
Edited 3 years ago

Well, looking at the scripts in your video, there are a lot of flaws in it.

Flaws:

  1. TextButtons don't work in workspace.

  2. LocalScripts don't work in workspace.

  3. The parameter of MouseButton1Click is nil.

  4. You are firing to server nil values.

Fix:

Well, I can't provide you the code identical to yours, but I will provide some examples.

Use ClickDetector instead of a TextButton. Make sure to put a NormalScript for its function. The parameter of ClickDetector is the player.

E.G.: Using ClickDetector for adding money.

local ClickDetector = script.Parent

ClickDetector.MouseClick:Connect(function(player)
    local leaderstats = player:WaitForChild("leaderstats")
    local Money = leaderstats:WaitForChild("Money")

    Money.Value = Money.Value + 10
end)
  1. Make sure to put ClickDetector outside SurfaceGui.

  2. You can also add Debounce to prevent spam.

  3. If you want it as a separate button, you can add a small part and put ClickDetector in the part.

Lemme know if it helps!

Answer this question