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

My GUI click function isnt working. why?

Asked by 2 years ago

Hey, im making a clicker type game. And i have a GUI button and if i click on it it gives me Multiplier stat, Which multiplies my money gained per click.

This is my code!

local plr = game.Players.LocalPlayer local clicked = false local StarterGui = game.StarterGui script.Parent.Activated:Connect(function(begin) local Money = game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Money") local Multiplier = game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Multiplier") local upgradecost1 = game.Players.LocalPlayer.Upgradecost1

clicked = true
if clicked and Money.Value > (upgradecost1.Value) then
    Multiplier.Value = Multiplier.Value +100

    upgradecost1.Value = upgradecost1.Value *1.05

    Money.Value = Money.Value -upgradecost1.Value
    wait(.9)
    clicked = false

end

end)

This is a child of a TextButton that is in a frame in a ScreenGUI in StarterGui,

I made it so whenever clicked it adds X amount of multipliers to my Multiplier.Value and the Upgradecost of the upgrade itself is a little more expensive every time. i have the Upgradecost as an StringValue in datastore ( to surpass the 9.22Qi limit). Now my Code works perfectly. But it stops working randomly after being clicked a couple of times and doesnt work Anymore. Eventhough i have enough Money.? I tried testing my game In the studio and On roblox itself still doesnt work.

0
Please fix your code, half of your code is outside the codeblock Borrahh 265 — 2y

1 answer

Log in to vote
0
Answered by 2 years ago

Instead of click you probably want to use this. replace click with this MouseButton1Click --make sure you connect the function with this

0
Thank you so much it worked :D M7mdbxgamer_YT 2 — 2y
0
Your Welcome!! XD theking66hayday 841 — 2y
Ad

Answer this question