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

Script doesn't work after being used twice?

Asked by 5 years ago

Hello, I have this script which just changes some things in lighting

But it doesn't work after you use it twice If you use this script:

local lighting = game.Lighting
local Debounce = false
local Speed = 1
local function Tween(t,s,d,p,o)
    return game:GetService("TweenService"):Create(o,TweenInfo.new(t,Enum.EasingStyle[s],Enum.EasingDirection[d]),p)
end

script.Parent.Touched:Connect(function()
    if not Debounce then
        Debounce = true
        Tween(Speed,"Sine","InOut",{Brightness = 0,FogStart = 50,FogColor = Color3.fromRGB(0,0,0),OutdoorAmbient = Color3.fromRGB(0,0,0)},lighting):Play()
    end
end)

It works completely fine, but if you use this script after it:

local lighting = game.Lighting
local Debounce = false
local Speed = 1

local function Tween(t,s,d,p,o)
    return game:GetService("TweenService"):Create(o,TweenInfo.new(t,Enum.EasingStyle[s],Enum.EasingDirection[d]),p)
end

script.Parent.Touched:Connect(function()
    if not Debounce then 
        Debounce = true
        Tween(Speed,"Sine","InOut",{Brightness = 1,FogStart = 0,FogColor = Color3.fromRGB(191, 191, 191),OutdoorAmbient = Color3.fromRGB(127, 127, 127)},lighting):Play()
    end
end)

It somehow doesn't work anymore, I don't get why this is happening someome please help me,

Thanks for your time

0
you didnt set the deboune back to false radusavin366 617 — 5y
0
^^^ SynthetickDev 188 — 5y

Answer this question