Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)


2 comments

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

0

updated my answer

1 answer

✓ Accepted answer

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

2 comments

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.

0

Thank you! A Remote Event worked! I will accept your answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.