#How do you make the light turn off when you start the game?
2 messages · Page 1 of 1 (latest)
local ProximityPrompt = script.Parent
local MovableLever = ProximityPrompt.Parent
local Model = MovableLever.Parent
local LightsGroup = Model.Lights
local Off = true
local TweenService = game:GetService("TweenService")
local TweenData = TweenInfo.new(0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut)
local Debounce = false
local function TurnOffLightsOnStart()
for Every, Part in pairs(LightsGroup:GetChildren()) do
if Part:IsA("Part") then
local Light = Part:FindFirstChildOfClass("PointLight")
Light.Enabled = false
Part.Material = "Plastic"
end
end
end
TurnOffLightsOnStart()
ProximityPrompt.TriggerEnded:Connect(function()
if Off == true then
local LeverAnimation = TweenService:Create(MovableLever,TweenData,{CFrame = Model.OnLever.CFrame})
LeverAnimation:Play()
LeverAnimation.Completed:Wait()
for Every, Part in pairs(LightsGroup:GetChildren()) do
if Part:IsA("Part") then
local Light = Part:FindFirstChildOfClass("PointLight")
Light.Enabled = true
Part.Material = "Neon"
end
end
Off = false
elseif Off == false then
local LeverAnimation = TweenService:Create(MovableLever,TweenData,{CFrame = Model.OffLever.CFrame})
LeverAnimation:Play()
LeverAnimation.Completed:Wait()
for Every, Part in pairs(LightsGroup:GetChildren()) do
if Part:IsA("Part") then
local Light = Part:FindFirstChildOfClass("PointLight")
Light.Enabled = false
Part.Material = "Plastic"
end
end
Off = true
end
end)