Wait(4) hangs forever

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    too wait 4 seconds then do a tween
  2. What is the issue? Include screenshots / videos if possible!
    i call wait(4) and it hangs
    Here is the code
local db = false
script.Parent.Touched:Connect(function(h)
	if db then return end
	if h.Parent:FindFirstChild('Humanoid') then
		if h.Parent.Name == script.Parent.Parent.Immune.Value then return end
		db = true
		h.Parent.Humanoid:TakeDamage(30)
		
		local sph = Instance.new('Part')
		sph.Shape = Enum.PartType.Ball
		sph.Position = script.Parent.Position
		sph.Parent = workspace
		sph.Size = Vector3.new(3,3,3)
		sph.TopSurface = Enum.SurfaceType.Smooth
		sph.Anchored = true
		sph.CanCollide = false
		sph.BottomSurface = Enum.SurfaceType.Smooth
		sph.Material = Enum.Material.ForceField
		sph.BrickColor = BrickColor.new('Really red')
		local ntw = game:GetService('TweenService'):Create(sph, TweenInfo.new(3), {Size=Vector3.new(20,20,20)})
		ntw:Play()
		print('played')
		print('damage time')
		local f = script.Script:Clone()
		f.Parent = sph
		f.Disabled = false
		print('done')
		wait(4)
		print('shrinking')
		ntw = game:GetService('TweenService'):Create(sph, TweenInfo.new(6), {Size=Vector3.new(-1,-1,-1)})
		
		ntw:Play()
		print('done')
		wait(4)
		print('deleting')
		sph:Destroy()
		f:Destroy()
		db = false
	end
end)

Any help would be appreciated!

I can guarantee you that wait(4) is not broken and your problem is something else. If you could provide more information about what is happening and what isn’t happening that’s supposed to be happening, that would be useful. It could have something to do with the script that’s inside of this script that you’re cloning, what does that one do?

1 Like

Does it actually print done and not print deleteing after that?

it prints done and not ‘shrinking’. Thats where it gets stuck

what does the output window look like? wait has never done this ever to me

I think that might be it. I think the script inside the script may be deleting it’s parent.

EDIT: When it is cloned, then activated.

It cant be, it is just a damage script.

maybe it’s a serverside lag issue, is the script you’re enabling doing a lot on enable?

No, its a simple ontouched damage.

Thanks for the help everyone, it turns out a script was deleting it! Silly me.

1 Like

Sorry, I did not know the contents of the script being cloned.

Try removing the wait and see what it does.