Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Animation gets stuck when using a health booster?

How this health booster works is like a medkit, equip it and left mouse click, and the medkit disappears, but the animation freezes in the position. I tried using various ways and I just can't get it fixed. Note that the tool is a one time use healer.

local Tool = script.Parent;

function onActivated()
	if not Tool.Enabled  then
		return
	end

	local h = Tool.Parent:FindFirstChild("Humanoid")
	if (h ~= nil) then
		wait(0)
		Tool:Remove()
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		h.Health = h.Health + 5
		wait(1)
		
	else
		return
	end

wait(1)

local p = Tool.Handle:Clone()

p.Transparency = 0

Tool.Parent.Torso["Right Shoulder"].MaxVelocity = 0.7
Tool.Parent.Torso["Right Shoulder"].DesiredAngle = 3.6
wait(.1)
Tool.Parent.Torso["Right Shoulder"].MaxVelocity = 1

local dir = h.Parent.Head.CFrame.lookVector
p.Velocity = (dir * 60) + Vector3.new(0,30,0)
p.CanCollide = true
Tool.Glass.Parent = p
p.Glass.Disabled = false
p.Parent = game.Workspace


script.Parent:Remove()

end

function onEquipped()
	--Tool.Handle.OpenSound:play()
end

script.Parent.Activated:connect(onActivated)
script.Parent.Equipped:connect(onEquipped)

1 answer

Hello, I will tell you what happens.

Why It Stops?: When a parent or the script is destroyed it stops working.

And well, you should create a normal animation with the animation editor plugin instead of making an animation with a script.

Ill tell you how to run an animation:

local Animation = script.Parent.Humanoid:LoadAnimation(script.Parent.Wave) --Finds the character's humanoid and animation.

Animation:Play()  --Plays the animation

Animation:Stop() --Stops the animation

Hope that i helped.

This discussion is preserved as it was. New answers, comments, and votes are closed.