Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Script welds tool to player, but its not working?

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

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.

2 comments

0

It gives the error " expected near end" ?

0

Sorry, fixed the error

This discussion is preserved as it was. New answers, comments, and votes are closed.