Hello everyone, I made a button that when player click it a door opens and appear a count down on the screen, and I decided whether player dies the local scripts got reset but the problem is when the count down finished the door doesn’t close itself
local script inside TextLabel:
--local door = game.Workspace.Door
for i = 40,0,-1 do
script.Parent.Text = i
wait(1)
local humanoid = player.Character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
script.Enabled = false
script.Parent.Visible = false
if i == 0 then
script.Parent.Text = "Time's Up"
wait(1)
script.Parent.Visible = false
end
end)
end
another local script inside StarterPlayerScripts:
local door = game.Workspace.Door
local sound = game.Workspace["Dish Sound"]["Dishes Washed"]
local sponge = game.Workspace.spomge.ClickDetector
local player = game.Players.LocalPlayer
local gui = player.PlayerGui:WaitForChild("Contador").Count.LocalScript
local text = player.PlayerGui:WaitForChild("Contador").Count
local player = game.Players.LocalPlayer
sponge.MouseClick:Connect(function(action)
if db == false then
db = true
door.Transparency = 1
door.CanCollide = false
door.Decal1.Transparency = 1
door.Decal2.Transparency = 1
sound:Play()
gui.Enabled = true
text.Visible = true
local humanoid = player.Character:WaitForChild("Humanoid")
humanoid.Died:Connect(function()
script.Enabled = false
door.Transparency = 0
door.CanCollide = true
door.Decal1.Transparency = 0
door.Decal2.Transparency = 0
text.Visible = false
wait(1)
script.Enabled = true
wait(40)
db = false
door.Transparency = 0
door.CanCollide = true
door.Decal1.Transparency = 0
door.Decal2.Transparency = 0
text.Visible = false
--gui.Enabled = false
end)
end
end)
well it’s not a model it’s a part with decals and canCollide itself once time player clicks a button that it’s a part too, everything worked fine but since I did the reset local script stuff it doesn’t close once the countdown finished
when player is death the local scripts will reset but since you told me that I removed the "Humanoid.Died:Connect(Function()” now the local scripts doesn’t reset
Try my newest edit, see if it works for you.
I just saw you were enabling then disabling the script.
The script disables its-self without being enabled.
I just tested again your script and it didn’t work because the db was not called so I added that and it works but the problem again is the door that doesn’t close back @CloudYugen
Hi @SuguruDev I just modify your script and it works perfectly, but a simple error occurs when the player clicks the button again it appears 0 (zero), it means that the text doesn’t update but the door closes at time