Script in ServerScriptService used to weld the tool:
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local M6D = Instance.new("Motor6D", char["Right Arm"])
M6D.Name = "ToolGrip"
char.ChildAdded:Connect(function(child)
if child:IsA("Tool") and child:FindFirstChild("BodyAttach") then
M6D.Part0 = char["Right Arm"]
M6D.Part1 = child.BodyAttach
end
end)
end)
end)
LocalScript under tool used to play animation:
local sign = script.Parent
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
function equip()
local equipAnimation = Instance.new("Animation")
equipAnimation.AnimationId = "rbxassetid://(animation id)"
local loadedequipAnimation = char.Humanoid:LoadAnimation(equipAnimation)
loadedequipAnimation:Play()
end
sign.Equipped:Connect(equip)
No errors in console. Any help on this please?
Edit: Just tested with an animation that only moves the handle. It works, but for some reason the equip animation doesn’t?
EDIT: Haha nevermind it works perfectly. I just realized that I moved the handle BEFORE I started animating, which kind of screwed everything up.
I figured out how to fix it, but I’m not sure how to describe it.
The code for the tool handle is:
local Player = game:GetService(“Players”).LocalPlayer
local mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Tool = script.Parent
local ToolGrip = Tool.Parent:WaitForChild(“ToolGrip”)
local BodyAttach = Tool:FindFirstChild(“BodyAttach”) or error(“Tool must have a BodyAttach part”)
local function equip()
BodyAttach.Parent = Character
BodyAttach.Anchored = false
ToolGrip.Part1 = BodyAttach
end
Tool.Equipped:Connect(equip)
function onUnequip()
ToolGrip.Part1 = nil
BodyAttach.Anchored = true
BodyAttach.Parent = Tool
end
Tool.Unequipped:Connect(onUnequip)
local function onDrag()
local drag = Instance.new(“BodyPosition”)
drag.P = 2000
drag.D = 100
drag.maxForce = Vector3.new(math.huge, math.huge, math.huge)
drag.position = mouse.Hit.p
drag.Parent = Tool
coroutine.resume(coroutine.create(function()
while wait(.1) do
drag.position = mouse.Hit.p
end
end))
mouse.Button1Up:Wait()
drag:Destroy()
end
mouse.Button1Down:Connect(onDrag)
The code for the animation is:
local Player = game:GetService(“Players”).LocalPlayer
local mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Tool = script.Parent
local ToolGrip = Tool.Parent:WaitForChild(“ToolGrip”)
local BodyAttach = Tool:FindFirstChild(“BodyAttach”) or error(“Tool must have a BodyAttach part”)
local function equip()
BodyAttach.Parent = Character
Body