Code after wait won't happend

Hey i’m devfoll and i made a combat system this is the damage script. The problem is: that the code won’t run after the wait function but if i set the wait to 0.1 it will run but if i change it over 1 sec it won’t run.

local Debounce = false
local Debounce2 = false

script.Parent.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("Humanoid") and hit.Name == "Part" and Debounce == false then
		Debounce = true
		hit.Parent.Humanoid.Health -= 30
		local Hit = Sound:Clone()
		Hit.Parent = hit
		Hit:Play()
		wait(0.9)
		Debounce = false
	elseif hit.Name == "ATM" then
		hit.Effects.Punch:Play()
		print(hit.Debounce.Value)
		if hit.Debounce.Value == false then
		local Number = tonumber(hit.BillboardGui.TextLabel.Text)
		if Number > 1 then
		Number -= 1
			hit.BillboardGui.TextLabel.Text = Number
			else	
				local ATM = hit
				hit.Effects.Punch:Play()
				hit.Debounce.Value = true
				local RandomX = math.random(1, 4)
				local RandomZ = math.random(1, 4)
				local RandomCash = math.random(50, 100)
				local Cash = game.ReplicatedStorage.Cash:Clone()
				local Cash = game.ReplicatedStorage.Cash:Clone()
				Cash.Parent = game.Workspace
				Cash.Position = ATM.Position + Vector3.new(RandomX, 0, RandomZ)
				ATM.BillboardGui.TextLabel.Text = 5
				Cash.BillboardGui.TextLabel.Text = RandomCash
				Cash.CashValue.Value = RandomCash
				local RandomX = math.random(1, 4)
				local RandomZ = math.random(1, 4)
				local RandomCash = math.random(50, 100)
				local Cash = game.ReplicatedStorage.Cash:Clone()
				Cash.Parent = game.Workspace
				Cash.Position = ATM.Position + Vector3.new(RandomX, 0, RandomZ)
				ATM.BillboardGui.TextLabel.Text = 5
				Cash.BillboardGui.TextLabel.Text = RandomCash
				Cash.CashValue.Value = RandomCash
				local RandomX = math.random(1, 4)
				local RandomZ = math.random(1, 4)
				local RandomCash = math.random(50, 100)
				local Cash = game.ReplicatedStorage.Cash:Clone()
				Cash.Parent = game.Workspace
				Cash.Position = ATM.Position + Vector3.new(RandomX, 0, RandomZ)
				ATM.BillboardGui.TextLabel.Text = 5
				Cash.BillboardGui.TextLabel.Text = RandomCash
				Cash.CashValue.Value = RandomCash
				local RandomX = math.random(2, 5)
				local RandomZ = math.random(2, 5)
				local RandomCash = math.random(50, 100)
				local Cash = game.ReplicatedStorage.Cash:Clone()
				Cash.Parent = game.Workspace
				Cash.Position = ATM.Position + Vector3.new(RandomX, 0, RandomZ)
				ATM.BillboardGui.TextLabel.Text = 5
				Cash.BillboardGui.TextLabel.Text = RandomCash
				Cash.CashValue.Value = RandomCash
				ATM.Effects.Smoke.Enabled = true
				ATM.Effects.Sparkles.Enabled = true
				print("Hello")
				wait(60)
				print("Worked")
				ATM.Debounce.Value = false
				ATM.Effects.Smoke.Enabled = false
				ATM.Effects.Sparkles.Enabled = false
				
			end
		end
	end
end)

The error is inside the elseif (i get no error message)
If u know the issue please respond since i don’t get this

which wait function? can u mark it

wait nvm i just remembered i deleted the script in another script after 1 sec or somthing

1 Like