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

How can I make a number value increase by clicking on a ImageButton?

Asked by 7 years ago

Hey Guys! So, a friend and I are working on a script. The whole purpose of the script is for a number value increase just by clicking on an ImageButton. What we tried was we using "MouseButton1Cick", if you can help us or give us any advice please do. We're working on a project and the purpose is for it to change everytime you click an arrow to the right.

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local number = script.Parent.Parent.Number

local humanoid = char:WaitForChild('Humanoid')
local torso = char:WaitForChild('Torso')
local torsogui = torso:WaitForChild('Number')
local guitext = torsogui:WaitForChild('TextLabel')
local debounce = true

function Increase()
    if number.Value < 0 then
        number.Value = number.Value + 1
    end
    number.Value = number.Value + 1
end

script.Parent.MouseButton1Click(function()
    if debounce then
        debounce = false
        Increase()
    wait(1)
    debounce = true
    end
end)

Here is a screenshot so you can understand. StarterGui - https://prnt.sc/fu2x93 Script - https://prnt.sc/fu2xi9

0
Any errors? Goulstem 8144 — 7y
0
Yes, everytime we click On the Image label, the number value does not increase. IIApexGamerII 76 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()
local number = script.Parent.Parent.Number.Number --You're using TextLabel, So I added the children of the TextLabel , which is the IntValue or Number

local humanoid = char:WaitForChild('Humanoid')
local torso = char:WaitForChild('Torso')
local torsogui = torso:WaitForChild('Number')
local guitext = torsogui:WaitForChild('TextLabel')
local debounce = true

function Increase()
    if number.Value < 0 then
        number.Value = number.Value + 1
    end
    number.Value = number.Value + 1
end

script.Parent.MouseButton1Click(function()
    if debounce then
        debounce = false
        Increase()
    wait(1)
    debounce = true
    end
end)


Ad

Answer this question