Somebody help me fix my value script

I don’t know what I could be doing wrong.


What’s supposed to happen is it prints “amount reached” when the value reaches four, but it doesn’t.

1 Like

Could you elaborate more on the problem and what I am exactly looking at?

when the int values reaches four, its supposed to print “amount reached” , like I said above.

How are you changing the value?

through a normal script.

im writing this so my post has 3o characters

Could you please show us that script?

image
As you can see here, you’re setting passedamount to true before you check if intvalue.Value >= amount

Instead, you should switch their positions and should work properly

intvalue.Changed:Connect(function()
if not passedamount and intvalue.Value >= amount then
passedamount = true
print("amount reached")
end
end)

Use GetPropertyChangedSignal() Instead.

There’s two problems, in both of your scripts your debounce systems are never reset so it’s impossible for them to be run again. In the one you just sent, set debounce to false again after the code is run.

it did not work

. . . . . . . . . . . . . … .

can you be any more specific?
also @EJQuik89 mentioned an issue in your other script

What can I be more specific about? It didn’t give any error message and it didn’t work. I’ve tried it both ways.

Change your original code to this:

intvalue.Changed:Connect:(Function()
    if passedamount == false then
        if intvalue.Value >= amount then
            print("Amount Reached")
            passedamount = true
        end
    end
end)

Your script that changes the int value should be changed to the following as well:

TouchPart.Touched:Connect:(function(hit)
    print("hit")
    if hit.Parent:FindFirstChild("Humanoid") then
        if not debounce then
            debounce = true
            print("Ready")
            value.Value = value.Value + 1
            print("added")
            debounce = false
        end
    end
end)


Let me know if this works!

I asked chatgpt and it fixed it for me, thanks for your help though.

Glad we could help. I wouldn’t recommend chatgpt for most scripts as it often outputs incorrect stuff. If you still want to, please use it before posting a thread on dev forum.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.