I have a local script (in StarterCharacterScripts) that changes the skybox and fog color depending on where the player is on the map. The skybox changing part seems to work quite well, but the color of the fog always remains the same.
local Char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local HRP = Char:WaitForChild("HumanoidRootPart")
local SkyBricks = workspace:WaitForChild("SkyBricks")
local SkyFolder = script:WaitForChild("Skyboxes")
local FoundSky = false
local colors = { -- The values are all set to really red as a test. The fog still doesn't change to red anyway.
["City"] = {255, 0, 0},
["Mountains"] = {255, 0, 0},
["SomeOtherPlace"] = {255, 0, 0},
["Default"] = {175, 206, 212}
}
local function ChangeSky(skybox)
if game.Lighting:FindFirstChildOfClass("Sky") then
game.Lighting:FindFirstChildOfClass("Sky"):Destroy()
end
skybox.Parent = game.Lighting
end
--------------------------------------------------
repeat wait(0.1) until #SkyBricks:GetChildren() == 14
HRP.Touched:Connect(function(hit)
if hit.Parent == SkyBricks then
ChangeSky(SkyFolder:FindFirstChild(hit.Name) and SkyFolder:FindFirstChild(hit.Name):Clone() or SkyFolder.Default:Clone())
end
end)
HRP.TouchEnded:Connect(function(hit)
if hit.Parent == SkyBricks then
ChangeSky(SkyFolder.Default:Clone())
end
end)
for _, v in pairs(SkyBricks:GetChildren()) do
for _, part in pairs(v:GetTouchingParts()) do -- get every part touching the skybrick
if part == HRP then -- if the part belonged to a character then
FoundSky = true
ChangeSky(SkyFolder:FindFirstChild(v.Name) and SkyFolder:FindFirstChild(v.Name):Clone() or SkyFolder.Default:Clone())
game.Lighting.FogColor = Color3.fromRGB(unpack(colors[v.Name])) -- where i believe it's failing
break
end
end
end
if not FoundSky then
ChangeSky(SkyFolder.Default:Clone())
end
No errors in the output, nothing telling me why this is happening. pls help
my bad, although i noticed that maybe v.Name could be the problem here, maybe you could try using the index of the value instead of the name of the value (if it still doesn’t work then you could maybe try doing
local color1,color2,color3,color4 = table.unpack(colors)
game.Lighting.FogColor = Color3.fromRGB(color1)
and instead of having ["City"] = {255, 0, 0} you just have the rgb values like
i think roblox assumes that ["City"] = {225, 0, 0} is the entire value, instead of just {255, 0, 0}, and if you want to find it later you can just use color1, color2, etc. since we’re basically just trying to set the table to multiple variables, i guess you could try to check by doing a quick print(v.Name)
This would mean “City” equals to this table, {255, 0, 0}.
So whenever we run unpack(colors["City"]), it turns the table labelled “City” into individual values, which we can then use as Color3 values. I really don’t understand how any of what you just said helps my situation.
oops, sorry about that, i’m not well versed with sub-tables, pretty sure the only thing i did was give an overcomplicated example that does practically the same thing LOL, anyways if you’re unpacking the values for say, [“City”] then wouldn’t that just return the numbers? you might have to explicitly define which values would be red, green, and blue.
(also, i’m pretty sure the brackets and quotations are also unnecessary)
although still i might just be spouting nonsense here lol, trying my best to help out here