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)```
#Script won't change the value of the BoolValue.
1 messages · Page 1 of 1 (latest)
Because you're changing the variable, not the object itself. The variable you set to the value of the master switch at that time
How? I changed the value to true..
** You are now Level 3! **
Just don't store the value.
So like the variable should be local MasterSwitchValue = MasterSwitchFolder.MasterSwitchValue, and when you need to update, you'd do MasterSwitchValue.Value = 1 or whatever
MasterSwitch is the BoolValue.
Okay cool then set it to true/false
It's checking the Value though. As it's for a different script.
Okay but my point still stands.
To check the value you'd just do if (MasterSwitchValue.Value) then
Right.
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
The script needs to check if the value was set to true before I can start the next part
Don't go adding redundant symbols
I used to call it preference, but I eventually grew out of that phase
Okay cool. We'll call it MasterSwitch instead so we can just do MasterSwitch.Value
I'm referring to the parentheses around your condition
Oh, I don't think that matters
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
Do you use the value in other scripts or just this one
Others.
Then that's fine
The other script checks to see if the value is active so I can turn the "lights" on
The Value dosen't change...
What I'm saying is that Ziffix was mentioning if the value is only used in this script it's better as a variable. But that's not the case so it's fine.
did you read what I said earlier
It didn't make sense
Do this babyshrek
** You are now Level 3! **
It shall work
spoonfeeding makes me sad
It doesnt print either??
Value objects are worse than I thought then
Just use attributes dude
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?
Wait so because it's under a Varible lua local
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
Please stop spoonfeeding man that's not great for people learning,..
Dawg its a value change he's got better things to learn
...
He'll get it down one day lol
So a Variable is the local MasterSwitch = #### part right?
They really need to learn everything, don't say that learning the fundamentals is bad
So we're gonna waste our time helpin the guy on a simple value?
Yes, that's you setting the variable to something
I feel like teaching about raycasts or other math would be more worth the time
It's not a waste of time to teach someone, don't be lazy
This stuff ain't hard to learn in the first place, the guy just needs a boost
waste the time is learning? waste the time is you writing a code that the person is probably not going to understand
😭
This just in, you can only teach advanced concepts
** You are now Level 22! **
at your logic beginners should directly learn raycasts...
Ok carry on teaching :D
what are you even saying bro
Just leave the thread
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
- I'm not trying it
- I want to be taught my mistake.
- The last one didn't even work anyways so I don't trust you
Lol cuz you set the variable as the value which I thought you set it as the object goofball
Leave the Thread mate.
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
Ohhhhh
It may be an oversimplified explanation, but hopefully that kinda gives you an idea of the issue
So Can I do MasterSwitchValue (To find the BoolValue) and then do MasterSwitchValue.Value
To get the Value's Status as such
Yes. Try changing your script a bit and see if it works. If not, come back and we can look over what you have
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)
you can do local MasterSwitchValue = MasterSwitchFolder.MasterSwitchValue, which stored the reference into the variable, so it's basically like MasterSwitchValue is a different name for MasterSwitchFolder.MasterSwitchValue
local MasterSwitchValue = MasterSwitchFolder.MasterSwitchValue
Would that work?
Then do MasterSwitchValue.Value
Yep! Give it a go.
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?
Yeah! That looks good
It didn't work
** You are now Level 4! **
Can you see the other script it's connected to and see if I've done something wrong there?
I think I may of
Is that script you gave a LocalScript or regular Script?
Regular.
let's look at the other script then
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
Same issue as the last script here
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
I'm glad I was able to help! I do like to try and actually give people knowledge so they can grow
Don't forget to edit the tags of the post and add the "Solved" tag!
My mate has something say to you rq
👂
Thanks mate for helping us, really appreciate it!
He's my mate I'm working with :D
Thank you so much mate, appreiate your help though!
Good luck to the both of you then!
Thank you!!
:D