#my color changing script doesnt work and im confused

1 messages · Page 1 of 1 (latest)

shadow wagon
#

local lightonoff = game.ReplicatedStorage.chamberlights
print("rr")
-- local colorchange = game.ReplicatedStorage.chamberlightsColor
lightonoff.Changed:Connect(function(v)
print("got it!!")
if v == false then
for _, i in pairs(script.Parent:GetChildren()) do
if i:IsA("SpotLight") or i:IsA("PointLight") then
if i.Parent:IsA("BasePart") then
i.Parent.BrickColor = BrickColor.new("Really black")
elseif i.Parent:IsA("UnionOperation") then
i.Parent.Color = Color3.fromRGB(0,0,0)
end
end

    end
elseif v == true then
    for _, i in pairs(script.Parent:GetChildren()) do
        if i:IsA("SpotLight") or i:IsA("PointLight") then
            if i.Parent:IsA("BasePart") then
                i.Parent.BrickColor = BrickColor.new("Institutional white")
            elseif i.Parent:IsA("UnionOperation") then
                i.Parent.Color = Color3.fromRGB(255,255,255)
            end
        end

    end
end

end)

coral flicker
#

can you d`o

```lua



#

cant really understand like this

#

@shadow wagon

versed shuttle
#

game.ReplicatedStorage

#

💔

#

pack it up brotein shake

shadow wagon
#

none of that is helpful

coral flicker
#

just do
lua

#

gng wth

#

do 3 `

#

type lua

#

and close it

#

it formats it

shadow wagon
#
print("rr")
-- local colorchange = game.ReplicatedStorage.chamberlightsColor
lightonoff.Changed:Connect(function(v)
    print("got it!!")
    if v == false then
        for _, i in pairs(script.Parent:GetChildren()) do
            if i:IsA("SpotLight") or i:IsA("PointLight") then
                if i.Parent:IsA("BasePart") then
                    i.Parent.BrickColor = BrickColor.new("Really black")
                elseif i.Parent:IsA("UnionOperation") then
                    i.Parent.Color = Color3.fromRGB(0,0,0)
                end
            end
            
        end
    elseif v == true then
        for _, i in pairs(script.Parent:GetChildren()) do
            if i:IsA("SpotLight") or i:IsA("PointLight") then
                if i.Parent:IsA("BasePart") then
                    i.Parent.BrickColor = BrickColor.new("Institutional white")
                elseif i.Parent:IsA("UnionOperation") then
                    i.Parent.Color = Color3.fromRGB(255,255,255)
                end
            end

        end
    end
end) ```
#

does that activate a neuron in yoru brain or something

coral flicker
#

it frickin formats it for gods sake

#

discord does it

shadow wagon
#

skip a line after type lua?

#

i aint a neanderthal

coral flicker
#

yes

shadow wagon
#

explain

coral flicker
#

bro u gonna do it or no?

#

GNG IT FORMATS IT

shadow wagon
#

i dont get what u want

coral flicker
#

like this

lime halo
coral flicker
#

yes

#

that

#

ty pyro 🙏

shadow wagon
#
local lightonoff = game.ReplicatedStorage.chamberlights
print("rr")
-- local colorchange = game.ReplicatedStorage.chamberlightsColor
lightonoff.Changed:Connect(function(v)
    print("got it!!")
    if v == false then
        for _, i in pairs(script.Parent:GetChildren()) do
            if i:IsA("SpotLight") or i:IsA("PointLight") then
                if i.Parent:IsA("BasePart") then
                    i.Parent.BrickColor = BrickColor.new("Really black")
                elseif i.Parent:IsA("UnionOperation") then
                    i.Parent.Color = Color3.fromRGB(0,0,0)
                end
            end
            
        end
    elseif v == true then
        for _, i in pairs(script.Parent:GetChildren()) do
            if i:IsA("SpotLight") or i:IsA("PointLight") then
                if i.Parent:IsA("BasePart") then
                    i.Parent.BrickColor = BrickColor.new("Institutional white")
                elseif i.Parent:IsA("UnionOperation") then
                    i.Parent.Color = Color3.fromRGB(255,255,255)
                end
            end

        end
    end
end)
pastel adder
#
local lightonoff = game.ReplicatedStorage.chamberlights

lightonoff.Changed:Connect(function(v)
    print("got it!!")
    if v == false then
        for _, v in ipairs(script.Parent:GetChildren()) do
            if v:IsA("SpotLight") or v:IsA("PointLight") then
                if v.Parent:IsA("BasePart") then
                    v.Parent.Color = BrickColor.new("Really black")
                elseif v.Parent:IsA("UnionOperation") then
                    v.Parent.Color = Color3.fromRGB(0,0,0)
                end
            end
            
        end
    elseif v == true then
        for _, i in pairs(script.Parent:GetChildren()) do
            if i:IsA("SpotLight") or i:IsA("PointLight") then
                if i.Parent:IsA("BasePart") then
                    i.Parent.Color = BrickColor.new("Institutional white")
                elseif i.Parent:IsA("UnionOperation") then
                    i.Parent.Color = Color3.fromRGB(255,255,255)
                end
            end

        end
    end
end) ```
#

try that

#

if it doesn't work i dunno

coral flicker
#

you should do lightonoff.Value

shadow wagon
#

...

lime halo
shadow wagon
#

.Changed requires the BoolValue, not the Value of the BoolValue

coral flicker
#

huh

#

i never use that

#

try lightonoff.Value instead

shadow wagon
#

the .changed isnt the issue

#

that runs perfectly

coral flicker
#

it isnt

#

the issue is

#

if v == false then

lime halo
#

If you are only interested in listening to the change of one specific property, consider using the GetPropertyChangedSignal() method instead.

coral flicker
#

try

if lightonoff.Value == false then

shadow wagon
#

it passes the new value, wdym

lime halo
coral flicker
#

it doesnt

#

the value is already changed

coral flicker
shadow wagon
#

does this answer your question

coral flicker
#

can u just try?

shadow wagon
#

ok

#

nope

#

it doesnt work

lime halo
shadow wagon
#

i clicked + near replicatedstorage

coral flicker
#

hold on it says Workspace.Lights

#

is the value in replicated

shadow wagon
#

yeah

#

that-

coral flicker
#

or workspace

shadow wagon
#

yes

#

its in replicated

lime halo
lime halo
shadow wagon
#

boolvalue uses a boolean

coral flicker
#

is the script in the lights folder

#

or wherever you need it

lime halo
#

boolvalue is not a boolean

coral flicker
#

you are using script.parent

shadow wagon
coral flicker
shadow wagon
vivid cedar
#

I think he meant that boolvalue is an instance to store a boolean

#

but boolvalue is an instance

shadow wagon
#

yes

#

and its value is a boolvalue

coral flicker
# shadow wagon

is the script a modulescript or where is the actual script

shadow wagon
#

its a serverscript in a folder

#

and it runs

coral flicker
#

uhm

#

you are doing script.parent

#

is there a folder there

shadow wagon
#

yes

#

it looks for children

#

which are spotlights

#

which are all in folder

#

well somewhere in the folder, but it looks everywhere

lime halo
#

that error doesn't match with your code

shadow wagon
#

thats what the other guy recommended

shadow wagon
lime halo
#

line 4 is lightonoff.Changed:Connect(function(v) so regardless of if it exists or not, local lightonoff = game.ReplicatedStorage.chamberlights is either instance or nil, not a boolean. so idk what you did to it

coral flicker
#

gng i got no clue

shadow wagon
#

no no its detecting that boolean

#

its not changing colors tho

lime halo
#

maybe you're looking at the wrong script

shadow wagon
#

no im not

coral flicker
shadow wagon
#

i already did

#

did you not see the script?

coral flicker
#

oh ye

lime halo
#

bait

shadow wagon
#

ok i see the issue

#

stupid ass roblox

coral flicker
#

what was it

shadow wagon
#

it used to detect all the children in children

#

now it doesnt

#

ill try something new

lime halo
#

bro put (true).Changed:connect() just for funnies. bruh why