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

Why is it not working when I make a script to turn the bool value on?

It is a very simples script, I don't know if I am missing some rules..

local dark = game.Workspace.Dark.Value
local light = script.Parent:FindFirstChild("Sector 1 Light")

if dark == true then
	light.BrickColor = BrickColor.new("Really black")
	
end

the game.Workspace.Dark is a bool value that I have in the workspace. I made a script inside it telling it to immediately go to true, but the script right here that you are seeing is in a light. This light is not changing brickcolors.

1 comment

0

Light doesn’t take a brick color. Try changing the time .

1 answer

Hello.


The problem with your script is that the if statement would only run once and end the script.

To fix this, you must connect the dark value to a Changed event. It will fire whenever its value is changed.


Also, I removed the .Value in the dark variable as the variable stores a boolean from the start of the game.


Anyways, here's your fixed script:

local dark = game.Workspace.Dark
local light = script.Parent:FindFirstChild("Sector 1 Light")

dark.Changed:Connect(function()
	if dark.Value == true then
	    light.BrickColor = BrickColor.new("Really black")
	end
end)

I hope this helps, cheers!

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