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

How do i make an aimation for a model like a sword play when someone clicks while holding the sword?

How do i make my sword do my sword animation when i click while holding the sword, or any other sword?

2 answers

from my understanding you want to play an animation when he click while equipping a tool so firstly insert a local script inside any tool you want and then write this script:

local tool = script.Parent -- the tool
local player = game.Players.LocalPlayer -- the player
local newAnim = Instance.new("Animation",script) -- we insert an animation inside the script
newAnim.AnimationId = "rbxassetid://animationID" -- change animationID to your animationID
local char = player.Character or player.CharacterAdded:Wait() -- the character of the player
local debounce = true -- debounce
tool.Activated:Connect(function() -- activated event fires when the player clicks while equipping the tool
	if debounce == true then -- checks if debounce is true
		debounce = false -- we set it to false so the animation doesnt keep on re-playing
		local animtrack = char.Humanoid:LoadAnimation(newAnim) -- the animation track to play
		animtrack:Play() -- playing it
		debounce = true -- after the animation finishes we set debounce back to true
	end
end)

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