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

Sword Script Will Not Animate When Running The Animate Function?

Is there something i'm doing wrong?

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()

local Tool = script.Parent

local Equipped = false

--/ Animation Controler
local CurrentAnim = nil
local Animation = nil

local Animations = {
	Swing = "http://www.roblox.com/asset/?id=2560427208",
}

function animate(Key)
	if Animations[Key] then
		Animation = Instance.new("Animation")
		Animation.AnimationId = Animations[Key]
		local AnimTrack = Character.Humanoid:LoadAnimation(Animation)
		AnimTrack:Play()
		CurrentAnim = AnimTrack
		AnimTrack.Stopped:Connect(function()
			CurrentAnim = nil
			AnimTrack:Destroy()
			Animation = nil
		end)
	end
end

--/ Functions
Tool.Equipped:Connect(function()
	print("Equipped "..Tool.Name)
	Equipped = true
end)

Tool.Unequipped:Connect(function()
	print("Unequipped "..Tool.Name)
	Equipped = false
end)

Tool.Activated:Connect(function()
	print("Activated "..Tool.Name)
	if Equipped then
		animate("Swing")
		print("Animated")
	end
end)

It doesn't print Any Errors.

1 answer

✓ Accepted answer

Make sure your animation level is "Action", action is the most prioritized animations and will play over movement, idle, and core.

The levels go as such...

Action -- Highest

Movement

Idle

Core -- Lowest

Go to the priority section of this page

1 comment

0

Thank you! It works perfectly now, did not know about that xd

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