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.
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
Well, looking at the scripts in your video, there are a lot of flaws in it.
Flaws:
TextButtons
don't work in workspace.
LocalScripts
don't work in workspace.
The parameter of MouseButton1Click
is nil
.
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)
Make sure to put ClickDetector
outside SurfaceGui
.
You can also add Debounce to prevent spam.
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!