I’ve been working on a game and I was trying to make a tool weld to the character, and I’ve looked through some documentation and I just don’t get what’s wrong with my code.
--//Player and Tool
local Pickaxe = script.Parent
local Character = Pickaxe.Parent
local Player = game.Players:GetPlayerFromCharacter(Character.Parent)
--//Animations
local Animations = Pickaxe.Animations
local Idle = Animations.Idle
local Swing = Animations.Swing
if not Character or not Character.Parent then
Character = Player.CharacterAdded:Wait()
end
function Equipped()
local Weld = Instance.new("Weld", Pickaxe.PickaxeMod.Handle)
Weld.Part0 = Pickaxe.PickaxeMod.Handle
Weld.Part1 = Player["RightHand"]
Weld.C0 = CFrame.new(0, 0, 0) + Vector3.new(0,Player["RightHand"],0)
end
function UnEquipped()
for i,v in ipairs(Pickaxe:GetChildren()) do
if v:IsA("Weld") then
v:Destroy()
end
end
end
Pickaxe.Equipped:Connect(Equipped())
Pickaxe.Unequipped:Connect(UnEquipped())
When run in studio, mind you this is for a R15 Rig, I get the error
Which wouldn’t usually be a problem but I’ve been looking at others’ posts and their script seems to work for them.
Any help would be appreciated.