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

My Clicker Game Has A Problem..?

I'm making a clicker game, and I don't know how to make this shop function work. Basically, there is a textbutton that gives you a boost for each click, but you have to have 100 clicks for it. It does detect the 100 clicks, BUT, then I can press it over and over again, even if I am under 100 clicks. Can anyone help? Here's my current script:

local player = game.Players.LocalPlayer
local clicks = player.leaderstats.Clicks
function shop()
script.Parent.Activated:Connect(function()
		if script.Parent.Activated then
	script.Parent.Activated:Connect(function()
		clicks.Value = clicks.Value - 100
		script.Parent.Parent.click.Activated:Connect(function()
			clicks.Value = clicks.Value + 1
end) end) end end) end
while true do
	wait()
	if clicks.Value >= 100 then break
end
shop()
end

BTW: I am not asking for a whole new script, I just need to be guided in the right direction. Thank you!

21 comments

1

what do you mean by " BUT, then I can press it over and over again, even if I am under 100 clicks. "

0

You are only supposed to be able to buy the upgrade if you have equal to or over 100 clicks.

0

But, you can keep buying it. Even if under 100 clicks.

0

Ohh, you need an if statement that checks if they have 100 clicks or more then

0

I have that in the script. Still dosen't work.

0

can you post a gif or something? im a bit confused what you're trying to do

0

Alright.

0

also why do you have this twice?

0

script.Parent.Activated:Connect(function() if script.Parent.Activated then script.Parent.Activated:Connect(function()

0

That's just how it works... And I can't post a gif. I'll explain in as much depth as I can. So. I am clicking. I get past 100. I can upgrade, but I try to spam click. Then my clicks go into negatives, because the upgrade is still processing. The loop doesn't detect if the clicks are under 100 anymore.

0

Well, the reason is because once you break the loop, it's done

0

Well, thats the problem, I don't wanna keep putting the same loop over and over again.

0

something like that is what you're trying to do?

0

if so, the script is in answers

0

That is not it.

0

It's supposed to remove 100 clicks AND add 1 click to each click.

0

you need another value then, named Power or something, increase it by 1 when it reaches 100

0

Wdym..?

0

so you mean you want to click 100 times and make it when you click after that, to do 2 clicks at once instead of 1.?

0

i edited the code so you can kinda see what i mean

1 answer

✓ Accepted answer
local player = game.Players.LocalPlayer
local clicks = player.leaderstats.Clicks

script.Parent.MouseButton1Click:Connect(function()
	if clicks.Value >= 100 then    
        clicks.Value = clicks.Value - 100
		else
	clicks.Value = clicks.Value + clicks.Power.Value --make a Number value for this, and set it to 1, if you want it higher, just add to it        
	end 
end) 

1 comment

0

It worked, thank you so much!

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