You don’t need to for loop it, you’ve already been given the answer in this post: Script not detecting if value - #2 by Zerxiase
Are you doing this in a server script or a local script?
try this code:
local RS = game:GetService("ReplicatedStorage")
local play = true
local debounce = false
local Turned = RS:WaitForChild("Turned")
while play do
Turned.Changed:Connect(function()
if Turned.Value == true then
if not debounce then
debounce = true
script.Parent.BrickColor = BrickColor.new("Dark green")
game.ReplicatedStorage.Temp.Value += 1
task.wait(1)
debounce = false
else
script.Parent.BrickColor = BrickColor.new("Really red")
end
end
end)
end
This is not working, like I said before it won’t work detecting if the value is true. I don’t know why.
Nope, not working. I did:
local RS = game.Workspace
local play = true
local debounce = false
local Turned = RS.Cooling1:WaitForChild("TurnPart")
RS.Values.Turned:GetPropertyChangedSignal("Value"):Connect(function(TheChangedValue)
print("works")
if not debounce then
debounce = true
script.Parent.BrickColor = BrickColor.new("Dark green")
game.ReplicatedStorage.Temp.Value += 1
task.wait(1)
debounce = false
else
script.Parent.BrickColor = BrickColor.new("Really red")
end
end)
…and the script won’t print “works.”
Your problem has been fixed. You’ve been using a local script and letting the server handle the rest of the coding. Local scripts are scripts that only the client can see while server scripts are scripts that only the server can see and read…
1 Like
ohhhhhhh, it wasn’t working but I posted a while wait() do after the value changed function. Thanks!
no problem… make sure to mark my post as the solution.
1 Like