RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"a roblox script that when you get closer to a part named "test" it makes the ambient more red"
-- server script local part = game.Workspace.test local function updateAmbient() for _, player in ipairs(game.Players:GetPlayers()) do local character = player.Character if character then local distance = (character.HumanoidRootPart.Position - part.Position).magnitude local redValue = math.clamp(1 - (distance / 100), 0, 1) player:FindFirstChild("PlayerGui"):SetAttribute("RedValue", redValue) end end end while true do updateAmbient() wait(0.5) end -- local script local playerGui = game.Players.LocalPlayer:WaitForChild("PlayerGui") while true do local redValue = playerGui:GetAttribute("RedValue") game.Lighting.Ambient = Color3.new(redValue, 0, 0) wait(0.5) end