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

IntValue ignores the fact that it's value changes. Why?

Asked by 4 years ago

I made a script where as long as it's activated, a loop runs to increase IntValueA by IntValueB.

For Example: IntValueA = 0 IntValueB = 10

The first loop runs, and IntValueA is now 10, it runs again and it becomes 20. Normal and works perfect. If I change IntValueB however, it still increases by 10 instead of whatever I set it to. Why?? Also, Damage is IntValueB, Charge is IntValueA.

local debounce = false
local damage = script.Parent.Damage 

script.Parent.Activated:Connect(function()
    if debounce==false then
    debounce = true
    script.Parent.Charging.Value = true
    while script.Parent.Charging.Value==true do 
            print(damage.Value)
            script.Parent.Charge.Value = script.Parent.Charge.Value +(damage.Value)
            print ("obama")
            if script.Parent.Charging.Value==false then 
            break
            end
            wait(1)
            end
    end
end)

script.Parent.Deactivated:Connect(function()
    print ("Nobama")
    script.Parent.Charging.Value = false
    wait(0.5)
    script.Parent.Charge.Value = 0
    wait(1.5)
    debounce = false
end)


0
Is this a Script or a LocalScript? If this is a Script and you are updating Damage on the client then this script wont see any changes as it wont be replicated. You would want to look at updating it via RemoteEvent if this is the case vector3_zero 1056 — 4y
0
updated my answer Azure_Kite 885 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

How did you change the value of intValueB?

Make sure you didnt change the one insideStarterPack

but instead the one inside the player's Backpackor the player's character if equipped

Edit :

Did you change the value using a localscript?

It will only change the value locally and wont be replicated to the server and other players

so try doing it via a server script or use remote event

0
I have a script inside a GUI, if a player presses a button his intValueB changes, when I check the value of intValueB, it does change but it does not add the update amount and still adds by the old one. RoblotXRB 3 — 4y
0
Thank you! A Remote Event worked! I will accept your answer. RoblotXRB 3 — 4y
Ad

Answer this question