Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

ambience and brightness randomly going up?

Asked by 3 years ago

so i have this script that on touch makes both lightning darkness and ambience a little darker, however after a few touches, the ambience and brightness randomly start going up instead of darker, whats the issue?

local notouchagain = false
script.Parent.Touched:Connect(function(hit)
    if hit.Parent.ClassName == "Model" then

        if game.Lighting.Ambient == Color3.new(0,0,0) then
        else
            if notouchagain == false then
                notouchagain = true
                local CurrentLighting = game.Lighting.Ambient
                local e = Vector3.new(5,5,5)/255
                local vectorcolour = Vector3.new(CurrentLighting.R, CurrentLighting.G , CurrentLighting.B)
                vectorcolour = vectorcolour - e 

                game.Lighting.Ambient = Color3.new(vectorcolour.X,vectorcolour.Y,vectorcolour.Z)
            game.Lighting.Brightness = game.Lighting.Brightness - 0.05
                script.Parent:Destroy()
            end
            end
    end

end)
0
Well, if a model hits it then the ambience/lighting will go up. Instead of doing if ClassName is Model, do if hit.Parent:FindFirstChild('Humanoid'). Rinextel 291 — 3y

Answer this question