#I made this script and theres a error, It says Instance is not a valid member of Lighting "Lighting"

41 messages · Page 1 of 1 (latest)

keen crest
#
    local Light = game:GetService("Lighting")
    local atmo = Instance.new("Atmosphere")
    
    if Light:FindFirstChild("Atmosphere") then
        return
    end
    atmo.Parent = Light
    Light.Atmosphere.Color = Color3.fromRGB(255, 255, 255)
    Light.Atmosphere.Decay = Color3.fromRGB(5, 58, 122)
end

game.Workspace.OceanBackgroundEffect.Touched:Connect(OceanEffect)```
#

make sure to delete any atmosphere you have in lighting before you use this

latent arch
#

would this work I tried not to completely copy your code function OceanEffect()
local light = game:GetService("Lighting")
local Atmosphere = game.Workspace.Instance.new("Atmosphere")
Atmosphere.Color = Color3.fromRGB(255, 255, 255)
Atmosphere.Decay = Color3.fromRGB(5, 58, 122)
Atmosphere.Glare = 10
Atmosphere.Haze = 10

    Atmosphere.Parent = light
if light.FindFirstChild("Atmosphere") then return
end

end

game.Workspace.OceanBackgroundEffect.Touched:Connect(OceanEffect)
keen crest
#

try it out

#

it seems right

latent arch
#

this means that you cant make 1000x from touching the OceanBackGround Part right if light.FindFirstChild("Atmosphere") then return
end

keen crest
#

yes

#

but

#

you should put that above

#

local Atmosphere

#

so it doesnt even create it if its already there

#

if light.FindFirstChild("Atmosphere") then return

latent arch
#

this? function OceanEffect()
local light = game:GetService("Lighting")
if light.FindFirstChild("Atmosphere") then return
end
local Atmosphere = game.Workspace.Instance.new("Atmosphere")
Atmosphere.Color = Color3.fromRGB(255, 255, 255)
Atmosphere.Decay = Color3.fromRGB(5, 58, 122)
Atmosphere.Glare = 10
Atmosphere.Haze = 10

    Atmosphere.Parent = light
if light.FindFirstChild("Atmosphere") then return
end

end

game.Workspace.OceanBackgroundEffect.Touched:Connect(OceanEffect)
bright flowerBOT
#

studio** You are now Level 1! **studio

keen crest
#

yes and delete the copy of it below

#

so like this

latent arch
#

I forgot ro but I did

keen crest
#
    local light = game:GetService("Lighting")
    if light.FindFirstChild("Atmosphere") then return
    end
    local Atmosphere = game.Workspace.Instance.new("Atmosphere")
    Atmosphere.Color = Color3.fromRGB(255, 255, 255)
    Atmosphere.Decay = Color3.fromRGB(5, 58, 122)
    Atmosphere.Glare = 10
    Atmosphere.Haze = 10

    Atmosphere.Parent = light
end

game.Workspace.OceanBackgroundEffect.Touched:Connect(OceanEffect)```
#

that should only make 1

latent arch
#

yea it look like that exactly I think

#

I got a question, so why can I do light.Instance.new("Atmosphere") like I did on my old script

keen crest
#

you mightve had another atmosphere already

#

idk why but its much better to make it organized

#

like make

#

local atmo = Instance.new("Atmosphere")

latent arch
#

I did have another atmosphere so I could copy the values and I think i ran it with it

#

ill check later

#

the code is inside the OceanBackground Part should it be in workspace or somewhere else?

keen crest
#

workspace is fine, or serverscriptservice

latent arch
#

on this line of code the .new in front of the Instance is a different color and a error saying instance isnt a valid member of workspace how do i fix this local Atmosphere = game.Workspace.Instance.new("Atmosphere")

keen crest
#

just do

#

local Atmosphere = Instance.new("Atmosphere")

#

as long as you define it its fine

#

thats probably why its erroring

latent arch
#

oh and you define the Varibles parent here Atmosphere.Parent = light

#

Its working now

#

and I think I learnt why it was changing the .news color

#

because I put game.Workspace.Instance.new it put Instance as a Instance inside Workspace but ebcause it couldnt find it it error.

#

Thank you for your help it works now

keen crest
#

yes np

#

enjoy