BoolValue Check not working

local prompt = script.Parent.Parent:WaitForChild("DrivePrompt")
while true do
	print(script.Parent.Parent.Locked.Value)
	if script.Parent.Parent.Locked.Value == false then
		prompt.Enabled = true
	else
		prompt.Enabled = false
	end
	wait(0.001)
end

When i check the boolvalue to true it’s still print false
even i tried to make it true by using command
workspace.RealingZeeKungsCar.Locked.Value = true still not working
any help please?

Is this Server Script? If it’s make sure you are changing the value to true or false on server not on client.

1 Like

Thank you!!
I need to change value in Server Sided Console so it will works!

No problem, glad that I helped you :wink:!

1 Like

By the way, this is a tangent but you can do this much more efficiently using Roblox Signals

local prompt = script.Parent.Parent:WaitForChild("DrivePrompt")
local locked = script.Parent.Parent.Locked

prompt.Enabled = locked.Value
locked.Changed:Connect(function() 
    prompt.Enabled = locked.Value
end)

What this does is registers an “Event” for when the value of Locked changes, and then only runs your code when that happens. This means you don’t have to constantly check :slight_smile:

EDIT: Check out @EmbatTheHybrid 's answer for working code :stuck_out_tongue:

1 Like

You’re close, it’s better to do this

local car = script.Parent.Parent
local prompt = car:WaitForChild("DrivePrompt")
local locked = car:WaitForChild("Locked")

prompt.Enabled = not locked.Value
locked.Changed:Connect(function(newVal)
	print(newVal)
	prompt.Enabled = not newVal
end)

Because in his code, if Locked is false then the prompt enables, and vice versa, so you need to use not

2 Likes

Thank you Everyone that help me I will try all the script you guys replied

1 Like

You’re right! I overlooked this. Thank you :slight_smile: I will amend my answer to point to yours.

2 Likes