I’m trying to change the lighting of the game locally so only the players client is affected, but my script only works for one part at a time. I’ve tried to group the “SkyChanger” parts in the workspace and create a table and run with that but then my script does nothing but doesn’t error so I don’t know what’s wrong with it.
local Lighting = game.Lighting
local SkyFolder = game.ReplicatedStorage.Lighting
local debounce = false
local part = game.Workspace:WaitForChild("SkyChanger")
part.Touched:Connect(function(touched)
if touched.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(touched.Parent)
if player then
if player == game.Players.LocalPlayer then
if debounce == false then
debounce = true
game.Lighting:ClearAllChildren()
task.wait(0.5)
local getSky = SkyFolder:FindFirstChild(part.Selection.Value)
for i, v in pairs(getSky:GetChildren()) do
local cloneSky = v:Clone()
cloneSky.Parent = game.Lighting
end
task.wait(5)
debounce = false
end
end
end
end
end)
This is the version of my script that actually works, however obviously it will only work for the 1st “SkyChanger” part found in the workspace. Any tips on making this script work for multiple parts? (Sorry i’m new to scripting)