Hi,
I’m completely lost on using Tools. I’ve tried to search up tutorials for weapon systems, but I have no idea how you: play animations on tools (and the player), have the tool be animated, all that stuff. I’m completely lost. I actually have no idea how the tools work, like how do I make it so I don’t need a handle but it’s still welded?
Tools have neither of that.
You load animation into Animator inside humanoid.
It can affect all joints parented to the model (including tools).
Tools by themselves are only capable of being moved from backpack to player character, firing Activated/Deactivated.
As well as creating a Weld for Handle part inside the tool according to the grip position.
That’s it! All functional tools have, pretty much.
For more info, read the Roblox docs: https://create.roblox.com/docs/reference/engine/classes/Tool#Deactivated
Set Tool.RequiresHandle = false, play the animation on the character Humanoid Animator, and attach the tool model to the hand with a Motor6D. Example LocalScript placed inside the Tool
As and untested that most likely will not work as is, but is showing the steps needed.
local Players = game:GetService("Players")
local tool = script.Parent
tool.RequiresHandle = false
local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://ANIM_ID"
local track
tool.Equipped:Connect(function()
local pl = Players.LocalPlayer
local ch = pl.Character or pl.CharacterAdded:Wait()
local hum = ch:WaitForChild("Humanoid")
local animator = hum:FindFirstChildOfClass("Animator") or Instance.new("Animator",hum)
track = animator:LoadAnimation(anim)
track:Play()
local part = tool.PrimaryPart or tool:FindFirstChildWhichIsA("BasePart")
if part then
local hand = ch:WaitForChild("RightHand")
local m = Instance.new("Motor6D")
m.Part0 = hand
m.Part1 = part
m.C0 = hand.CFrame:Inverse() * part.CFrame
m.Parent = hand
end
end)
tool.Unequipped:Connect(function()
if track then track:Stop() end
local hand = Players.LocalPlayer.Character and Players.LocalPlayer.Character:FindFirstChild("RightHand")
if hand then
for _,c in pairs(hand:GetChildren()) do
if c:IsA("Motor6D") and c.Part1 and c.Part1.Parent==tool then c:Destroy() end
end
end
end)
Does it have to be on equipped?
I made it so that its welded to the Torso instead (and the server does it). Is this still okay? I want the gun to be visible at all times, essentially, so its welded permanently.
I don’t really understand what’s going on with the Motor6D? What’s with the :Inverse()? Sorry, new to this.
Yeah, I understand most of the signals and equipped stuff. I already have a way to handle that, it’s just the actual tool itself. The welding and what not, the animation handling, but you did say the Animator will handle it.
Suppose I have a tool, which I am animating, welded to the Torso. When I export and play this animation, Would I also have to make the Motor6D weld in the Torso at runtime? Or do I just weld anywhere? Seems to me like I have to weld it to the Torso.
You don’t need editing tool itself or breaking it’s handles.
It will be animated regardless aslong as its a descedant/child of a Character that contains Animator.
Oh, alright. So my method of just welding everything on the server (using Motor6Ds) is ok?
I’m gonna try testing around with this tool. I just have a probl;em where this tool was animated with the Handle welded to the right arm, so if I weld it to Torso, it doesn’t seem to work…
Are there any examples of like gun systems using tools? And its an OTS system, so not viewmodels and stuff?
Just some type of an example.. It’s sloppy and off the top of my head untested.. Consider it a raw example.
Thank you for all the help guys.
@2112Jay , @Yarik_superpro
I think I’ve figured it out now.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.