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

Why isn't my IntValue changing in this OnServerEvent?

Asked by
rexpex 45
8 years ago

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:

01replicatedstorage = game:GetService("ReplicatedStorage")
02ChargeAnim = replicatedstorage:FindFirstChild("RicoClass").Charging
03tool = script.Parent.Parent
04cooldown = false
05 
06ChargeAnim.OnServerEvent:connect(function()
07local charge = script:FindFirstChild("Charging")
08charge.Value = charge.Value + 1
09print(charge.Value)
10end)

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

0
When using RemoteEvents, there should be a local script to fire it. Can you show us the script for it? starlebVerse 685 — 8y
0
the local script its in is really long, but the remote event is working its just not changing the int value rexpex 45 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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

Your script would look like this:

1replicatedstorage = game:GetService("ReplicatedStorage")
2ChargeAnim = replicatedstorage:FindFirstChild("RicoClass").Charging
3tool = script.Parent.Parent
4cooldown = false
5ChargeAnim.OnServerEvent:connect(function()
6    script:FindFirstChild("Charging") .Value = script:FindFirstChild("Charging") .Value + 1
7    print(charge.Value)
8    end)
0
i think i've tried this before but i guess i'll see if ur version works rexpex 45 — 8y
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..) rexpex 45 — 8y
Ad

Answer this question