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

My Clicker Game Has A Problem..?

Asked by
Aztralzz 169
4 years ago

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!

1
what do you mean by " BUT, then I can press it over and over again, even if I am under 100 clicks. " RobloxianDestory 262 — 4y
0
You are only supposed to be able to buy the upgrade if you have equal to or over 100 clicks. Aztralzz 169 — 4y
0
But, you can keep buying it. Even if under 100 clicks. Aztralzz 169 — 4y
0
Ohh, you need an if statement that checks if they have 100 clicks or more then DarkDanny04 407 — 4y
View all comments (17 more)
0
I have that in the script. Still dosen't work. Aztralzz 169 — 4y
0
can you post a gif or something? im a bit confused what you're trying to do RobloxianDestory 262 — 4y
0
Alright. Aztralzz 169 — 4y
0
also why do you have this twice? RobloxianDestory 262 — 4y
0
script.Parent.Activated:Connect(function() if script.Parent.Activated then script.Parent.Activated:Connect(function() RobloxianDestory 262 — 4y
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. Aztralzz 169 — 4y
0
Well, the reason is because once you break the loop, it's done DarkDanny04 407 — 4y
0
Well, thats the problem, I don't wanna keep putting the same loop over and over again. Aztralzz 169 — 4y
0
something like that is what you're trying to do? RobloxianDestory 262 — 4y
0
if so, the script is in answers RobloxianDestory 262 — 4y
0
That is not it. Aztralzz 169 — 4y
0
It's supposed to remove 100 clicks AND add 1 click to each click. Aztralzz 169 — 4y
0
you need another value then, named Power or something, increase it by 1 when it reaches 100 RobloxianDestory 262 — 4y
0
Wdym..? Aztralzz 169 — 4y
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.? RobloxianDestory 262 — 4y
0
i edited the code so you can kinda see what i mean RobloxianDestory 262 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago
Edited 4 years ago
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) 
0
It worked, thank you so much! Aztralzz 169 — 4y
Ad

Answer this question