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

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

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

1 answer

Log in to vote
0
Answered by 7 years ago

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)
0
i think i've tried this before but i guess i'll see if ur version works rexpex 45 — 7y
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 — 7y
Ad

Answer this question