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

Function won't detect NumberValue change?

Asked by 5 years ago

I have been working on a fighting game where you can send out a blast forward from your hands. When you press Z, a large blast is fired and a hitbox is cloned and put in to the local character's model. After that, the script inside the hitbox that was cloned is re enabled and this simple script runs. Afterwards, the script is destroyed and then you can fire the blast again after the cooldown.

All worked well up until I tried making a value that you can change to determine how much damage your blast did to another player. For every player that spawns in, they get their own folder in replicated storage which stores their variables, etc. Strength is one of those variables.

The problem I'm having is the script works fine, but when I attempt to change Strength's numbervalue the previous value is still being loaded, even though the referencing should be fine. Please help!

local char = script.Parent.Parent
local playername = script.Parent.Parent.Name
local folder = game:GetService("ReplicatedStorage"):WaitForChild(playername)
hasbeenhit = false

script.Parent.Touched:Connect(function(touched)
if touched.Parent ~= nil and touched.Parent:FindFirstChild("Humanoid") and hasbeenhit== false then
    if touched.Parent ~= char and touched ~= char then
    touched.Parent.Humanoid:TakeDamage(10 + folder.Vars.Strength.Value/2)
                hasbeenhit = true
            else    
                --do nothing            
            end
    end
hasbeenhit = false
end)
0
This is most likely occurring because you are changing the value from the client. Any changes done through a local script cannot be seen by the server, so the value doesn't appear to change. You can fix this by changing the value from a normal script. mattscy 3725 — 5y
0
This is a normal script, summoned from another script, triggered by a remote function from a local script. AgencyDrone 0 — 5y

Answer this question