Does anyone know what is the issue, when I click the button on UI it won’t change brightness of the PointLight in workspace. I’ve tried it in server script and in local script.
I have tried looking on DevHub but I haven’t find anything new.
Note: Code below is in a local script.
local MainFrame = script.Parent
local PlayClapMusicButton = MainFrame.Clap
local CloseCurtainsButton = MainFrame.Close_Curtains
local OpenCurtainsButton = MainFrame.Open_Curtains
local PlayEndingMusicButton = MainFrame.Ending_Music
local ExitButton = MainFrame.Exit
local PlayIntermissionMusic = MainFrame.Intermission
local LightsOnButton = MainFrame.Lights_On
local LightsOffButton = MainFrame.Lights_Off
local CinemaAudio = game.Workspace.cinemaarea
local StageLight = game.Workspace.stagelight.PointLight
local LightsOn = false
local CurtainsOpen = false
function TurnLightsOn()
while wait(0.1) do
StageLight.Brightness = StageLight.Brightness + 0.1
if StageLight.Brightness == 3 then
break
end
end
end
function TurnLightsOff()
while wait(0.1) do
StageLight.Brightness = StageLight.Brightness - 0.1
if StageLight.Brightness == 0 then
break
end
end
end
PlayClapMusicButton.MouseButton1Click:Connect(function()
CinemaAudio.SoundId = ""
CinemaAudio:Play()
end)
PlayIntermissionMusic.MouseButton1Click:Connect(function()
CinemaAudio.SoundId = ""
CinemaAudio:Play()
end)
PlayEndingMusicButton.MouseButton1Click:Connect(function()
CinemaAudio.SoundId = ""
CinemaAudio:Play()
end)
ExitButton.MouseButton1Click:Connect(function()
MainFrame:Destroy()
end)
LightsOnButton.MouseButton1Click:Connect(function()
TurnLightsOn()
end)
LightsOffButton.MouseButton1Click:Connect(function()
TurnLightsOff()
end)
If you have a solution or an idea I would love to hear it.
i am a bit confused on how that would work.
I have never seen someone do that so i don’t know if it is a normal thing but i just have no idea how that would work
when you do while you need to give it a true statement for it to loop so if you pass in something that is false or nil it won’t loop so doing wait(0.1) there would give it a nil so it wouldn’t do anything
--Similar to this:
local isOpen = false
local function OpenLights()
if isOpen == false then
isOpen = true
Lightbulb.PointLight.Enable = true
end
end
local function OpenLights()
if isOpen == true then
isOpen = false
Lightbulb.PointLight.Enable = true
end
end
while StageLight.Brightness > 0 do
-- also when dealing with while loops always remember to add a wait() in it or the game will crash
-- decrease brightness
end
local TweenService = game:GetService("TweenService")
local FadeInfo = TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local isOpen = false
local function OpenLights()
if isOpen == false then
TweenService:Create(Lightbulb.PointLight, FadeInfo, {Brightness = 3}):Play()
isOpen = true
end
end
local function CloseLights()
if isOpen == true then
TweenService:Create(Lightbulb.PointLight, FadeInfo, {Brightness = 1}):Play()
isOpen = false
end
end
here slowly makes it brighter and brighter and brighter probably “if StageLight.Brightness == 3 then” this area is not working
edit : it makes it stop in 3 but probably it needs to be changed or script’s that stage is not working