#Script won't change the value of the BoolValue.

1 messages · Page 1 of 1 (latest)

delicate prawn
#
local LightFixtures = workspace["Light Fixtures"]
local Floor1 = LightFixtures["Floor 1"]
local Room1 = Floor1["Room 1"]


local MasterSwitchFolder = Room1.MasterSwitch
local MasterSwitchValue = MasterSwitchFolder.MasterSwitchValue.Value

local HotelCardModel = MasterSwitchFolder.HotelCard

local CD = HotelCardModel.ClickDetectorPart.ClickDetector
local Card = HotelCardModel.Keycard

CD.MouseClick:Connect(function(player)
    if MasterSwitchValue == false then
        MasterSwitchValue = true
        Card.Transparency = 0
        print("F1, R1 - MasterSwitch On")
    elseif MasterSwitchValue == true then
        MasterSwitchValue = false
        Card.Transparency = 1
        print("F1, R1 - MasterSwitch Off")
    end
end)```
analog valve
delicate prawn
junior fulcrumBOT
#

studio** You are now Level 3! **studio

delicate prawn
#

How od I fix it then

#

If you'd not mind helping with it :D

analog valve
delicate prawn
#

MasterSwitch is the BoolValue.

analog valve
delicate prawn
#

It's checking the Value though. As it's for a different script.

analog valve
delicate prawn
#

Right.

sinful nexus
#
    MasterSwitchValue.Value = not MasterSwitchValue.Value
    if MasterSwitchValue.Value == false then
        Card.Transparency = 0
        print("F1, R1 - MasterSwitch On")
    elseif MasterSwitchValue.Value == true then
        Card.Transparency = 1
        print("F1, R1 - MasterSwitch Off")
    end
end)``` Just decided to do a little edit. not boolvalue just changes it for ya
delicate prawn
#

The script needs to check if the value was set to true before I can start the next part

vernal topaz
#

I used to call it preference, but I eventually grew out of that phase

analog valve
vernal topaz
#

I'm referring to the parentheses around your condition

analog valve
sinful nexus
#

Ngl though I recommend Attributes instead though

#

Object values are so 2020

vernal topaz
#

Lol

#

If the value has no presence outside of the script, it can be kept as state instead

#

Aka a variable with a boolean value, not a BoolValue

delicate prawn
#

Your confusing my small brain

#

What do I do to fix my script then

analog valve
delicate prawn
#

Others.

analog valve
delicate prawn
#

The other script checks to see if the value is active so I can turn the "lights" on

delicate prawn
analog valve
analog valve
delicate prawn
#

It didn't make sense

junior fulcrumBOT
#

studio** You are now Level 3! **studio

sinful nexus
#

It shall work

analog valve
delicate prawn
#

It dosen't

#

I already tried.

sinful nexus
#

It doesnt print either??

#

Value objects are worse than I thought then

#

Just use attributes dude

analog valve
# delicate prawn I already tried.

The issue is that you're putting the value of MasterSwitchValue into a variable. That isn't a link to the value itself, so you're only changing the variable and not the value you think you're changing. With me so far?

delicate prawn
#

Wait so because it's under a Varible lua local

sinful nexus
#
local Floor1 = LightFixtures["Floor 1"]
local Room1 = Floor1["Room 1"]


local MasterSwitchFolder = Room1.MasterSwitch
local MasterSwitchValue = MasterSwitchFolder.MasterSwitchValue

local HotelCardModel = MasterSwitchFolder.HotelCard

local CD = HotelCardModel.ClickDetectorPart.ClickDetector
local Card = HotelCardModel.Keycard

CD.MouseClick:Connect(function(player)
    MasterSwitchValue.Value = not MasterSwitchValue.Value
    if MasterSwitchValue == false then
    
        Card.Transparency = 0
        print("F1, R1 - MasterSwitch On")
    elseif MasterSwitchValue == true then
        Card.Transparency = 1
        print("F1, R1 - MasterSwitch Off")
    end
end)``` Ok copy n paste this and see how it does
uneven arrow
#

bro stop 😭

#

don't spoonfeed

analog valve
sinful nexus
#

Dawg its a value change he's got better things to learn

uneven arrow
#

...

sinful nexus
#

He'll get it down one day lol

uneven arrow
#

you dont understand how shit is spoonfeed lol

#

is just not good to do it

delicate prawn
#

So a Variable is the local MasterSwitch = #### part right?

analog valve
sinful nexus
#

So we're gonna waste our time helpin the guy on a simple value?

analog valve
sinful nexus
#

I feel like teaching about raycasts or other math would be more worth the time

analog valve
sinful nexus
#

This stuff ain't hard to learn in the first place, the guy just needs a boost

uneven arrow
analog valve
#

This just in, you can only teach advanced concepts

junior fulcrumBOT
#

studio** You are now Level 22! **studio

uneven arrow
#

at your logic beginners should directly learn raycasts...

delicate prawn
uneven arrow
#

what are you even saying bro

sinful nexus
#

Well he's gotta know the result at least

#

Babyshrek lmk if that spoonful works

delicate prawn
sinful nexus
#

It should if the object value holds up to what I thought it would be

#

Jeez even the student turned on me, crazy alright bet

delicate prawn
sinful nexus
delicate prawn
#

Leave the Thread mate.

analog valve
# delicate prawn Ok carry on teaching :D

So bascially, .Value returns a boolean, which gets put into the variable.

The variable has no link to where it came from.

When you set the variable to MasterSwitchValue (not .Value) you're saving a reference to the BoolValue.

So because it's a reference, doing .Value will say "BoolValue, give me whatever Value is right now

delicate prawn
#

Ohhhhh

analog valve
# delicate prawn Ohhhhh

It may be an oversimplified explanation, but hopefully that kinda gives you an idea of the issue

delicate prawn
#

So Can I do MasterSwitchValue (To find the BoolValue) and then do MasterSwitchValue.Value

#

To get the Value's Status as such

analog valve
delicate prawn
#

Wait question

#

Can I do a local as a Variable and then get the boolvalue from that or do I need to make a direct link to it

#

(for my stacks)

analog valve
delicate prawn
#

local MasterSwitchValue = MasterSwitchFolder.MasterSwitchValue

#

Would that work?

#

Then do MasterSwitchValue.Value

analog valve
delicate prawn
#
local LightFixtures = workspace["Light Fixtures"]
local Floor1 = LightFixtures["Floor 1"]
local Room1 = Floor1["Room 1"]


local MasterSwitchFolder = Room1.MasterSwitch
local MasterSwitchValue = MasterSwitchFolder.MasterSwitchValue

local HotelCardModel = MasterSwitchFolder.HotelCard

local CD = HotelCardModel.ClickDetectorPart.ClickDetector
local Card = HotelCardModel.Keycard

CD.MouseClick:Connect(function(player)
    if MasterSwitchValue.Value == false then
        MasterSwitchValue.Value = true
        Card.Transparency = 0
        print("F1, R1 - MasterSwitch On")
    elseif MasterSwitchValue.Value == true then
        MasterSwitchValue.Value = false
        Card.Transparency = 1
        print("F1, R1 - MasterSwitch Off")
    end
end)```

Like that then?
delicate prawn
#

It didn't work

junior fulcrumBOT
#

studio** You are now Level 4! **studio

delicate prawn
#

Can you see the other script it's connected to and see if I've done something wrong there?

#

I think I may of

analog valve
delicate prawn
#

Regular.

analog valve
delicate prawn
#

I was told it can't be a LocalScript as it's not in referencing the LocalPlayer.

#
local LightFixtures = workspace["Light Fixtures"]
local Floor1 = LightFixtures["Floor 1"]
local Room1 = Floor1["Room 1"]

local MainRoomFixtures = Room1["Main Room Fixtures"]

local LightValue = MainRoomFixtures.Mirror.Model.Model.LightOn.Value
local MasterSwitchValue = Room1.MasterSwitch.MasterSwitchValue.Value
local MirrorLight = Room1["Main Room Fixtures"].Mirror.Mirror.Union

local On = MainRoomFixtures.Mirror.Model.Model.On
local Off = MainRoomFixtures.Mirror.Model.Model.Off
local CD = script.Parent

CD.MouseClick:Connect(function(player)
    if MasterSwitchValue == true then
        if LightValue == true then
            LightValue = false
            MirrorLight.BrickColor = BrickColor.new("Dark stone grey")
            MirrorLight.Material = "SmoothPlastic"
            On.Transparency = 1
            Off.Transparency = 0

        elseif LightValue == false then
            LightValue = true
            MirrorLight.BrickColor = BrickColor.new("Lily white")
            MirrorLight.Material = "Neon"
            On.Transparency = 0
            Off.Transparency = 1
        end
    elseif MasterSwitchValue == false then
        warn("MasterSwitch is not in")
    end
end)
#

I think I may have done something wrong

analog valve
delicate prawn
#

OMFG

#

IT WORKED

#

I'M SO HAPPY!

#

Thank you so much!

#

I really appreicate that so much, how you actually taught me instead of spoonfeeding me

analog valve
#

Don't forget to edit the tags of the post and add the "Solved" tag!

delicate prawn
#

My mate has something say to you rq

analog valve
jagged onyx
delicate prawn
#

He's my mate I'm working with :D

#

Thank you so much mate, appreiate your help though!

analog valve
#

Good luck to the both of you then!

jagged onyx
#

Thank you!!

delicate prawn
#

:D