Can somebody help my script

so im making a script that clones the sky inside the script and puts it in the Lighting and then once the value is 0 it will delete the sky inside the lighting
this is the script so far

while true do
	if game.ServerStorage.Value2.Value == 10 then 
	script.Sky.Parent = game.Lighting
	end
	if game.ServerStorage.Value2.Value == 0 then
		game.Lighting.Sky:Destroy()
	end
	wait(1)
end 


1 Like
local storage = game:GetService("ServerStorage")
local value2 = storage:WaitForChild("Value2")
local sky = script:WaitForChild("Sky")

value2.Changed:Connect(function(newVal)
	if newVal == 10 then
		sky.Parent = game.Lighting
	elseif newVal == 0 then
		sky:Destroy()
	end
end)

Also “ServerStorage” can only be accessed by server scripts, in case you didn’t know.

3 Likes

omg thank you so much! this helps a lot!