I have been recently trying to figure out how to weld a tool to a player so that it will follow the players animations. I in the end came out with this script but its not working. Anyone know why?
The script is a local script that is inside the tool under starterpack.
Here is the code
local tool = script.Parent local handle = tool:WaitForChild("Handle") local character repeat wait() character = game.Players.LocalPlayer.Character until character local rightArm = character:WaitForChild("Right Arm") local weld = Instance.new("Weld", handle) weld.Part0 = rightArm weld.Part1 = handle weld.C0 = (0, -1, 0, 1, 0, -0, 0, 0, 1, 0, -1, -0) = tool.Grip0 weld.C1 = tool.Grip end
What you pretty much did on local character repeat wait() would not work. It would error. Another thing that you have done wrong is that you declared the variable after you used the variable you have done local character repeat wait(). Here is the answer I think would fix your script.
local tool = script.Parent local handle = tool:WaitForChild("Handle") local character = game.Players.LocalPlayer.Character repeat character ~= nil wait() until character ~= nil local rightArm = character:WaitForChild("Right Arm") local weld = Instance.new("Weld", handle) weld.Part0 = rightArm weld.Part1 = handle weld.C0 = (0, -1, 0, 1, 0, -0, 0, 0, 1, 0, -1, -0) tool.Grip0 = weld.C0 weld.C1 = tool.Grip
Please accept my answer if it has worked. If not, please ask questions in the comments.