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

How do I fix a numbervalue not changing, even with no errors?

I have a script that is supposed to increase a numbervalue based on a boolvalue. However, it doesn't work, nor display any errors. I can't find out what's wrong.

while true do
	wait(0.3)
	if game.Workspace.Gasflow == true then
		script.Parent.Value = script.Parent.Value + 5
	end
	if game.Workspace.Gasflow == false then
			script.Parent.Value = script.Parent.Value - 5
	end
end

1 answer

✓ Accepted answer

You're asking if the bool value is nil, not whether its actual value is true or false. You forgot to say Gasflow.Value.

local Gasflow = workspace:WaitForChild("Gasflow")
local Dad = script.Parent

while true do
    wait(0.3)
    -- Ternary operator
    Dad.Value = Gasflow.Value and Dad.Value + 5 or Dad.Value - 5
    --[[ Same as 
    if Gasflow.Value then
        Dad.Value = Dad.Value + 5
    else
    	Dad.Value = Dad.Value - 5
    end 
	--]]
end

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