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

Why my script cant detect changes in the value of IntValue or NumberValue?

I have a problem that probably has an easy solution. Basically my script wont detect any changes in the value of NumberValues or IntValues. Here is my script that I made to test the problem:

local w = workspace

local v = w:FindFirstChild("Value")

while wait() do

print(v.Value)

end

As I said if I change the value from 0 to 1 it still prints it out as 0.

2 answers

✓ Accepted answer

General Practice

Use :WaitForChild() to make sure that a part exists, rather than :FindFirstChild()

Due to how while-loops are created, it is better to place the wait() inside the loop and replace it with true

Revised Server Script

local v = workspace:WaitForChild("Value")

while true do
    print(v.Value)
    wait()
end

Also make sure that when you test the change of the value that you are doing so on the Server since FilteringEnabled will prevent the changes on the Client from being replicated (Studio Test Servers will always display the Client first)

1 comment

0

I guess that was the Issue, I was changing the value on client while the script was running on server.

while wait() do print(game.Workspace.Value.Value) end

1 comment

0

doesnt change anything

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