Value checker won't function

I made a script that waits until a value is true until changing the parent part’s properties. It won’t change anything even if the value is true. Here is the script:

inRound = game.ReplicatedStorage.InRound

part = script.Parent

part.Velocity = Vector3.new(0,0,0)

if inRound == true then

    wait(5)

    part.Velocity = Vector3.new(0,0,100)

else

    part.Velocity = Vector3.new(0,0,0)

end
1 Like

I’m assuming you’re a scripting rookie, which is 100% not a problem! I’m just making the notation so I can adapt to how I can help you.

There’s a method called :GetPropertyChangedSignal(PropertyName) which returns an event signal so we can connect a function to this which fires every time the specific property has been changed.

How you can use this:

inRound = game.ReplicatedStorage.InRound

part = script.Parent

part.Velocity = Vector3.new(0,0,0)

inRound:GetPropertyChangedSignal("Value"):Connect(function()
	if inRound.Value then 
		-- we dont need to do inRound.Value == true because inRound.Value is already a boolean!
		
		wait(5)
		
		part.Velocity = Vector3.new(0,0,100)
		
	else
		
		part.Velocity = Vector3.new(0,0,0)
		
	end
end

We can even simplify this!

Simplified
inRound = game.ReplicatedStorage.InRound
part = script.Parent
part.Velocity = Vector3.new(0,0,0)

inRound:GetPropertyChangedSignal("Value"):Connect(function()
	part.Velocity = inRound.Value and Vector3.new(0,0,100) or Vector3.new(0,0,0)
end
1 Like

Your script did not work for some reason, so I made a few changes to it. Now it changes the velocity, but it won’t wait 5 seconds.

inRound = game.ReplicatedStorage.InRound
part = script.Parent
part.Velocity = Vector3.new(0,0,0)

inRound:GetPropertyChangedSignal("Value"):Connect(function()
	if inRound then
		wait(5)
		part.Velocity = Vector3.new(0,0,100)
	else
		part.Velocity = Vector3.new(0,0,0)
	end
end)

inRound and inRound.Value are two completely different things.

inRound is an object value, referring to the object which is located at game.ReplicatedStorage.InRound

inRound.Value is a boolean value (either true or false), which refers to inRound’s value if, which I assume, inRound is a BoolValue.

1 Like

Wow, I had no idea inRound and inRound.Value were different at all. I just assumed one was just a shorter way of saying it. One little detail completely changed the script! Thank you, this helps me a lot.

1 Like