Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

Script welds tool to player, but its not working?

Asked by 6 years ago

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

1 answer

Log in to vote
-1
Answered by 6 years ago
Edited 6 years ago

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.

0
It gives the error "<eof> expected near end" ? GottaHaveAFunTime 218 — 6y
0
Sorry, fixed the error saSlol2436 716 — 6y
Ad

Answer this question