Why doesn't my repeat wait() until work in this function?
function ontouched(part)
local hum = part.Parent:FindFirstChild("Humanoid")
if hum and game.Players:GetPlayerFromCharacter(part.Parent) and hum ~= nil then
local gui1 = game.Players:GetPlayerFromCharacter(part.Parent):WaitForChild("PlayerGui"):WaitForChild("Gui4"):WaitForChild("Frame")
local gui2 = game.Players:GetPlayerFromCharacter(part.Parent):WaitForChild("PlayerGui"):WaitForChild("Gui5"):WaitForChild("Frame")
local gui3 = game.Players:GetPlayerFromCharacter(part.Parent):WaitForChild("PlayerGui"):WaitForChild("Gui6"):WaitForChild("Frame")
game.Workspace.Dummy.Torso.Anchored = false
script.Parent.Position = Vector3.new(-50,50,50)
gui1.label1.Visible = false
gui2.label1.Visible = true
gui2.label1:Destry()
repeat wait() until game.Workspace.Dummy.Humanoid.Health == 0
gui3.label1.Visible = true
game.StarterPack.Sword.Enabled = true
wait(4)
end
end
script.Parent.Touched:connect(ontouched)