When the boss stops attacking i want him to have like a resting idle so the players can attack the boss
Here is the half of the script
while wait(5) do
if monster.Humanoid.Health > 0 then
monster.ForceField.Visible = true
HammerChallenge()
SpikeChallenge()
fireBallChallenge()
lavaChallenge()
print("Forcefield has been disabled!")
monster.ForceField.Visible = false
else
break
end
end
``
This doesn’t solve your issue, I don’t quite understand what you want. Underneath this is code block is a relevant question though.
You shouldn’t put your wait in the condition of the loop. It would be better to just use it inside of the loop. You are breaking if the condition of the if statement is false, which is what the condition part of the while loop is supposed to be used for.
while monster.Humanoid.Health > 0 do
monster.ForceField.Visible = true
HammerChallenge()
SpikeChallenge()
fireBallChallenge()
lavaChallenge()
print("Forcefield has been disabled!")
monster.ForceField.Visible = false
wait(5)
end
But as for the actual issue, do you have an animation you want to play specifically that you can’t figure out how to load on the boss? And if so, where in explorer is it?
monster.Humanoid.HealthChanged:Connect(function() -- instead of looping, just detect when the monster's health changes (to save on performance)
if monster.Humanoid.Health > 0 then
-- do stuff here
-- play the animation:
local animObj = Instance.new("Animation") -- creates a new animation instance
animObj.AnimationId = "rbxassetid://" .. 0000 -- the 0's represent the animation id (replace this with your animation id)
local animation = monster.Humanoid:LoadAnimation(animObj) -- create a new animation track
animation:Play() -- play the animation
-- do stuff here
end
end)
Also, is the monster a custom rig or is it a Roblox Rig?
while wait(5) do
if monster.Humanoid.Health > 0 then
monster.ForceField.Visible = true
HammerChallenge()
SpikeChallenge()
fireBallChallenge()
lavaChallenge()
print("Forcefield has been disabled!")
monster.ForceField.Visible = false
local animation = monster.animation name
monster.Humanoid:LoadAnimation(animation):Play()
else
break
end
end
You have to code when the boss is going to attack again, but just set the animation variable outside of the scope
local animation
monster.Humanoid.HealthChanged:Connect(function()
if monster.Humanoid.Health > 0 then
-- do stuff here
-- play the animation:
local animObj = Instance.new("Animation")
animObj.AnimationId = "rbxassetid://" .. 0000 -- replace this with your animation id
animation = monster.Humanoid:LoadAnimation(animObj) -- create a new animation track
animation:Play()
-- do stuff here
end
end)
-- do stuff the detect when the boss is going to attack again
animation:Stop() -- stop the animation
monster.Humanoid.HealthChanged:Connect(function()
if monster.Humanoid.Health > 0 then
HammerChallenge()
lavaChallenge()
SpikeChallenge()
fireBallChallenge()
-- play the animation:
local animObj = Instance.new("Animation")
animObj.AnimationId = "rbxassetid://" .. 6309496859 -- replace this with your animation id
animation = monster.Humanoid:LoadAnimation(animObj) -- create a new animation track
animation:Play()
-- do stuff here
end
end)
-- do stuff the detect when the boss is going to attack again
wait(10)
animation:Stop() -- stop the animation
The event was an example of how to use it, you have to code the actual system as I can’t do it
Detects when the boss takes damage
Plays the animation
Make the boss attack again
Stop the animation
If your system doesn’t use events then do this
local event = Instance.new("BindableEvent")
local animation
-- rest of the script
event.Event:Connect(function()
if animation then
animation:Stop()
end
end)
-- stuff that makes the boss attack again
event:Fire() -- this would fire the event when the scripts makes the boss attack again to stop the animation
local event = Instance.new("BindableEvent")
local animation
-- rest of the script
event.Event:Connect(function()
if animation then
monster.Humanoid.HealthChanged:Connect(function()
if monster.Humanoid.Health > 0 then
HammerChallenge()
lavaChallenge()
SpikeChallenge()
fireBallChallenge()
-- play the animation:
local animObj = Instance.new("Animation")
animObj.AnimationId = "rbxassetid://" .. 6309496859 -- replace this with your animation id
animation = monster.Humanoid:LoadAnimation(animObj) -- create a new animation track
animation:Play()
end
end)
-- do stuff the detect when the boss is going to attack again
wait(10)
animation:Stop() -- stop the animation
end
end)