Debugging Lighting Changes in Roblox

Thank you for the update. It seems that the server is detecting when a player touches the bloody biome, but the client-side lighting changes are not being applied. Let's focus on debugging the client-side script and ensure that the lighting changes are being executed correctly.

Here's an updated version of the client-side script with more detailed debugging:

-- LocalScript (BiomeLightingHandler)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Lighting = game:GetService("Lighting")

local SkyboxChangeEvent = ReplicatedStorage:WaitForChild("SkyboxChangeEvent")

local function onSkyboxChange(isBloody)
    print("SkyboxChangeEvent received:", isBloody)
    
    if isBloody then
        -- Set bloody skybox and atmosphere
        print("Setting Bloody atmosphere")
        Lighting.Ambient = Color3.new(1, 0, 0)
        print("Ambient set to:", Lighting.Ambient)
        Lighting.OutdoorAmbient = Color3.new(1, 0, 0)
        print("OutdoorAmbient set to:", Lighting.OutdoorAmbient)
        Lighting.ColorShift_Bottom = Color3.new(1, 0, 0)
        print("ColorShift_Bottom set to:", Lighting.ColorShift_Bottom)
        Lighting.ColorShift_Top = Color3.new(1, 0, 0)
        print("ColorShift_Top set to:", Lighting.ColorShift_Top)
        
        -- Add a red atmosphere
        local atmosphere = Lighting:FindFirstChild("Atmosphere") or Instance.new("Atmosphere")
        atmosphere.Parent = Lighting
        atmosphere.Density = 0.5
        atmosphere.Color = Color3.new(1, 0, 0)
        print("Atmosphere added and set to red")
        
        -- Change sky color
        local sky = Lighting:FindFirstChild("Sky") or Instance.new("Sky")
        sky.Parent = Lighting
        sky.SkyboxBk = "rbxassetid://6444884337"  -- Red skybox
        sky.SkyboxDn = "rbxassetid://6444884785"
        sky.SkyboxFt = "rbxassetid://6444884337"
        sky.SkyboxLf = "rbxassetid://6444884337"
        sky.SkyboxRt = "rbxassetid://6444884337"
        sky.SkyboxUp = "rbxassetid://6444884785"
        print("Sky changed to red skybox")
    else
        -- Set normal skybox and atmosphere
        print("Setting normal atmosphere")
        Lighting.Ambient = Color3.new(0.5, 0.5, 0.5)
        print("Ambient set to:", Lighting.Ambient)
        Lighting.OutdoorAmbient = Color3.new(0.5, 0.5, 0.5)
        print("OutdoorAmbient set to:", Lighting.OutdoorAmbient)
        Lighting.ColorShift_Bottom = Color3.new(0, 0, 0)
        print("ColorShift_Bottom set to:", Lighting.ColorShift_Bottom)
        Lighting.ColorShift_Top = Color3.new(0, 0, 0)
        print("ColorShift_Top set to:", Lighting.ColorShift_Top)
        
        -- Remove atmosphere
        local atmosphere = Lighting:FindFirstChild("Atmosphere")
        if atmosphere then
            atmosphere:Destroy()
            print("Atmosphere removed")
        end
        
        -- Reset sky color
        local sky = Lighting:FindFirstChild("Sky")
        if sky then
            sky.SkyboxBk = "rbxassetid://6444884337"  -- Default skybox
            sky.SkyboxDn = "rbxassetid://6444884785"
            sky.SkyboxFt = "rbxassetid://6444884337"
            sky.SkyboxLf = "rbxassetid://6444884337"
            sky.SkyboxRt = "rbxassetid://6444884337"
            sky.SkyboxUp = "rbxassetid://6444884785"
            print("Sky reset to default skybox")
        end
    end
    
    print("Lighting changes applied")
end

SkyboxChangeEvent.OnClientEvent:Connect(onSkyboxChange)
print("BiomeLightingHandler script loaded and connected to SkyboxChangeEvent")

-- Test the lighting changes
local function testLightingChanges()
    print("Testing lighting changes")
    onSkyboxChange(true)  -- Test bloody biome
    wait(5)
    onSkyboxChange(false)  -- Test normal biome
end

-- Uncomment the line below to test lighting changes when the script loads
-- testLightingChanges()

Debugging Steps:

  1. Replace the contents of the LocalScript (BiomeLightingHandler) in the player's PlayerGui with this updated script.
  2. Run the game and check the Output window in Roblox Studio for the debug messages from this client-side script.
  3. Look for these key messages:
    • "BiomeLightingHandler script loaded and connected to SkyboxChangeEvent" - Confirms the script is running and connected
    • "SkyboxChangeEvent received: true/false" - When the event is received from the server
    • "Setting Bloody atmosphere" or "Setting normal atmosphere" - When changing the lighting
    • Various "set to" messages - Confirming each lighting property change
    • "Lighting changes applied" - After all changes are made
  4. If you don't see these messages, ensure that the LocalScript is properly placed in the player's PlayerGui.
  5. To test the lighting changes directly, uncomment the `testLightingChanges()` line at the bottom of the script. This will force the lighting to change when the script loads, allowing you to see if the function works correctly.
  6. If the lighting changes work with the test function but not during gameplay, the issue might be with the server-side script not firing the event correctly.

Additional Troubleshooting:

  1. Check if there are any other scripts or plugins that might be interfering with the lighting changes.
  2. Verify that the SkyboxChangeEvent is being fired from the server when the player touches the bloody biome.
  3. Ensure that the Lighting service is not locked or controlled by another script.
  4. Try adding a small delay before applying the lighting changes, in case there's a timing issue:
    SkyboxChangeEvent.OnClientEvent:Connect(function(isBloody)
        wait(0.1)  -- Small delay
        onSkyboxChange(isBloody)
    end)
            

If you're still experiencing issues after implementing these changes, please provide the following information:

This additional information will help us pinpoint where the problem is occurring in the script execution.