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

How do you change a BooleanValue via script?

Basically I'm trying to get the booleanvalue to change, but it doesn't change at all. I'm pretty confused, so how would you change a booleanvalue via script?

local boolvalue = script.Parent.bool
local light = game:GetService("Lighting")
local alarm = script.Parent.Parent.alarm
local message = script.Parent.Parent.corevent
local temp = script.Parent.SurfaceGui.Text

while true do
	wait()
		if temp.Text == "1999°c" then
		boolvalue = true
		alarm.Looped = false
	elseif temp.Text == "2000°c" then
		script.Parent.Parent.Map.coremachine.coreOverheat.Fire.Enabled = true
		alarm.Looped = true
		boolvalue.Value = false
	
repeat
		
			
			message:Play()
			light.Ambient = Color3.new(150/255,0/255,0/255)
			alarm:Play()
			wait(0.2)
			light.Ambient = Color3.new(0/255,0/255,0/255)
			wait(0.9)
			light.Ambient = Color3.new(150/255,0/255,0/255)
until boolvalue.Value == true
		end
		end

3 answers

✓ Accepted answer

Revising my answer a third time because I made a mistake of putting stuff after the while true do loop lol

Try this and see if it works

local boolvalue = script.Parent.bool
local light = game:GetService("Lighting")
local alarm = script.Parent.Parent.alarm
local message = script.Parent.Parent.corevent
local temp = script.Parent.SurfaceGui.Text

local function change(v)
	if (v == false) then
        repeat
            message:Play()
            light.Ambient = Color3.new(150/255,0/255,0/255)
            alarm:Play()
            wait(0.2)
            light.Ambient = Color3.new(0/255,0/255,0/255)
            wait(0.9)
            light.Ambient = Color3.new(150/255,0/255,0/255)
        until boolvalue.Value == true
    end
end

boolvalue.Changed:Connect(change)
change(boolvalue.Value)

while true do
    wait()
        if temp.Text == "1999°c" then
        boolvalue.Value = true
        alarm.Looped = false
    elseif temp.Text == "2000°c" then
        script.Parent.Parent.Map.coremachine.coreOverheat.Fire.Enabled = true
        alarm.Looped = true
        boolvalue.Value = false
    end
end

4 comments

0

Oh it finally works! Omg thank you, also I was wondering where you learnt scripting? It's my third day scripting, I only have a head-start because I already know Java.

0

I learned it over time from many different places. The biggest place of learning I can think of is developer.roblox.com with all their documentation. Now that it's fixed, remember to mark the question as solved.

0

Yes I will after.. Also how do you navigate around in developer.roblox.com? Since it's uh, all bungled up?

0

If you go to "Learn Roblox" button at the top of the website, it will take you to some tutorials. You can scroll around in there to probably learn something new. Otherwise easier sources would be youtube or free models, but those are kinda hit and miss.

Hey bro, the it works what you did. You did it right and everything but this single line breaks the whole script it's the line 10

FIXED:

local boolvalue = script.Parent.bool
local light = game:GetService("Lighting")
local alarm = script.Parent.Parent.alarm
local message = script.Parent.Parent.corevent
local temp = script.Parent.SurfaceGui.Text

while true do
    wait()
        if temp.Text == "1999°c" then
        boolvalue.Value = true
        alarm.Looped = false
    elseif temp.Text == "2000°c" then
        script.Parent.Parent.Map.coremachine.coreOverheat.Fire.Enabled = true
        alarm.Looped = true
        boolvalue.Value = false

repeat


            message:Play()
            light.Ambient = Color3.new(150/255,0/255,0/255)
            alarm:Play()
            wait(0.2)
            light.Ambient = Color3.new(0/255,0/255,0/255)
            wait(0.9)
            light.Ambient = Color3.new(150/255,0/255,0/255)
until boolvalue.Value == true
        end
        end

You had it change the value "boolvalue" and it's an object so you can't change it's value, you forgot to add ".Value" to it.

There is a property in every value named "Value". In order to access this property, you must reference it (The Value Property) when talking about the name of the value. Line 10 is where you made the mistake!

For Example:

local bool = game.Workspace:FindFirstChild('BoolValue')

if 1+1 == 2 then
	bool.Value = true
	wait(2)
	bool.Value = false
end)

2 comments

0

The double equal sign is only used whenever your comparing two values and not when declaring.

0

Sorry I didn't mean to add that.

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