how do i make it so that when the player defeats the boss it will print “You win” but whenever i run the script after the function it would print “You win”.
coroutine.wrap(function()
while wait(2) do
if not canAttack then continue end
HammerChallenge()
-- example creation
monster.ForceField.Visible = false
local animObj = Instance.new("Animation")
animObj.AnimationId = "rbxassetid://" .. 6309504704
animation = monster.Humanoid:LoadAnimation(animObj)
animation:Play()
animation.Stopped:Wait() -- wait for it to end
local new = Instance.new("ForceField")
new.Parent = monster
end
end)()
wait(1)
print("You win")