I have tried to implement your script and it works fine. I found that you named your object as a door. Maybe the problem is on the script that is controlling that object.
I found the issue! Though am not sure how to fix it. This is the power system script.
local Power = game.ReplicatedStorage.Power
local PowerUsage = game.ReplicatedStorage.PowerUsage
game.ReplicatedStorage.NightStart.OnServerEvent:Connect(function()
while Power.Value > 0 do
Power.Value -= Power.Value >= PowerUsage.Value and PowerUsage.Value or Power.Value
task.wait(5 - PowerUsage.Value)
end
end)
local Debounce = false
while wait(0.1) do
game.Workspace.Power.SurfaceGui.PowerText.Text = "Power ".. Power.Value.. "%"
if Power.Value == 0 then
local Debounce = false
if Debounce == false then
Debounce = true
game.Workspace.DoorButton:Destroy()
game.Workspace.LightButton:Destroy()
game.Workspace.DoorButton2:Destroy()
game.Workspace.LightButton2:Destroy()
game.Workspace.Door:Destroy()
game.Workspace.Door2:Destroy()
game.Workspace.Power:Destroy()
game.Workspace.Sounds["FNaF 1 Door Light [Loop]"]:Stop()
game.Workspace.Sounds["FNaF 1 Door Light [Loop]2"]:Stop()
game.Workspace.Sounds["phone"]:Stop()
game.Workspace.Sounds["[FNAF: PhoneGuy Night 1]"]:Stop()
game.Workspace.Sounds["power outage sound effect"]:Play()
wait(1)
script:Destroy()
end
end
end
What is the issue? How does this script related to it? What are you expecting this script to do and what is it actually doing? please answer all of the questions so we can help as best as possible
right if you have a while loop the code after it will not run until the while loop has finished, you could move the while loop to the bottom or put it in a task.defer call like so
task.defer(function()
while wait(0.1) do
game.Workspace.Power.SurfaceGui.PowerText.Text = "Power ".. Power.Value.. "%"
-- etc ...
end
end)