Hey again! I just noticed that your tool has no handle.This means the tool will have no held item, but the existence of the “Sword” group seems to suggest you’d like to have one. In your script, you seem to be making a weld to the player’s arm manually, and this is almost never what you want to do.
Tool Hierarchy
Currently, you have a model inside a LocalScript inside the tool object, and this is pretty much just wrong, to be honest. Don’t worry! We all make mistakes. What you’ll most likely want to do is something like this:
(Please note that the part you intend to use as the tool must have the Name property set as “Handle” [with the capital H!])
Also in the screenshot above, please take note of the GripPos value I’ve pointed out in the tool object. This property can be used to offset the tool if you find the character is not holding it correctly. (click the down arrow and try changing the Y value, if it’s too high or low!)
More info on the tool object, its properties, and the proper hierarchy of a tool can be found on the wiki: http://wiki.roblox.com/index.php/Tools
The LocalScript (You didn’t use the code tag! ;-; )
I’ve taken the liberty to import the script you sent into studio and have a little look-see. Honestly, I can tell the first bit where it welds all the parts together is copy-pasted. How, you ask? Well, you forgot to set the C0 and C1 properties when you welded to the arm. Practice makes perfect, so don’t sweat it too much!
After sorting through all this weld business, I noticed another big issue. you’re instantiating an animation object every time you press a key. Here’s why this is an issue: As the player presses the key repeatedly to make the animation play, a new object is added each time. This can (and will) lead to client slowdowns over time, and as Sonic says, “That’s no good!” I’d personally recommend creating the animations once, near the beginning of the script:
After doing this, and adjusting the input code to match, it works.
For more information and a nice example on animations: http://wiki.roblox.com/index.php?title=Animations#Example
But there’s another problem that I simply can’t solve for you!
Sad but true, two of your animations don’t seem to load correctly. I’ve kept the ids as they were in the original script, and while the animation for the “E” key works, the other two do not. You may need to go find or upload some new animations!
CONCLUSION
Scripting is hard, I get it. It can take a lot of time and effort, but it really is rewarding. I think it’s wonderful that you’re making a tool, and give you my full support!
Here’s the finished script, but please do take the time to read the post, if you haven’t!
local plr = game.Players.LocalPlayer
local char = plr.Character
local animQ = Instance.new("Animation")
animQ.AnimationId = "rbxassetid://1192762732"
local animE = Instance.new("Animation")
animE.AnimationId = "rbxassetid://74894663"
local animF = Instance.new("Animation")
animF.AnimationId = "rbxassetid://1199630444"
game:GetService("UserInputService").InputBegan:connect(function(key,typ)
if not typ then
if key.KeyCode == Enum.KeyCode.Q then
local track = char.Humanoid:LoadAnimation(animQ)
track:Play()
elseif key.KeyCode == Enum.KeyCode.E then
local track = char.Humanoid:LoadAnimation(animE)
track:Play()
elseif key.KeyCode == Enum.KeyCode.F then
local track = char.Humanoid:LoadAnimation(animF)
track:Play()
end
end
end)