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

Why isn't my IntValue changing in this OnServerEvent?

I am trying to make a script that counts how long someone is holding a key but when i check the value in my tool the intValue isnt changing at all;meaning i can't check when the player stopped holding the button:

replicatedstorage = game:GetService("ReplicatedStorage")
ChargeAnim = replicatedstorage:FindFirstChild("RicoClass").Charging
tool = script.Parent.Parent
cooldown = false

ChargeAnim.OnServerEvent:connect(function()
local charge = script:FindFirstChild("Charging")
charge.Value = charge.Value + 1
print(charge.Value)
end)


the script is counting down but its not changing the int value

2 comments

0

When using RemoteEvents, there should be a local script to fire it. Can you show us the script for it?

0

the local script its in is really long, but the remote event is working its just not changing the int value

1 answer

✓ Accepted answer

Instead of using the variable 'charge', try using the proper location: script:FindFirstChid("Charging")

Your script would look like this:

replicatedstorage = game:GetService("ReplicatedStorage")
ChargeAnim = replicatedstorage:FindFirstChild("RicoClass").Charging
tool = script.Parent.Parent
cooldown = false
ChargeAnim.OnServerEvent:connect(function()
	script:FindFirstChild("Charging") .Value = script:FindFirstChild("Charging") .Value + 1
	print(charge.Value)
	end)

2 comments

0

i think i've tried this before but i guess i'll see if ur version works

0

Oh cool, i can call the the new value of the intvalue in other scripts so now it works(but the int value still isnt changing, odd..)

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