Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

4 comments

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.

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.

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.

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.

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.