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
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)