I am trying to weld a model to the character’s left hand but it doesn’t work
local Players = game:GetService("Players") local tool:Tool = script.Parent local model:Model local function Modelise() : Model local character = tool.Parent and tool.Parent:IsA("Model") and Players:GetPlayerFromCharacter(tool.Parent) and tool.Parent or nil if not character then warn("non") return end if typeof(model) == "Instance" then model:Destroy() end local Model = Instance.new("Model") Model.Parent = character local weld = Instance.new("Weld",Model) for _,part in tool:GetChildren() do if not part:IsA("BasePart") then continue end local new = part:Clone() new.Parent = Model new.Massless = true new.Destroying:Connect(function() print("nah") end) if part.Name == "Handle" then Model.PrimaryPart = new end end if Model.PrimaryPart then local lefthand:BasePart = character:FindFirstChild("LeftHand") if lefthand then Model.PrimaryPart:PivotTo(lefthand.CFrame*CFrame.fromEulerAngles(0,0,0)) weld.Part0 = Model.PrimaryPart weld.Part1 = lefthand weld.Enabled = true end end model = Model return Model end tool.Equipped:Connect(function() Modelise() end) tool.Unequipped:Connect(function() if model then model:Destroy() model = nil end end)
local Players = game:GetService("Players") local tool: Tool = script.Parent local model: Model local function Modelise(): Model local character = tool.Parent and tool.Parent:IsA("Model") and Players:GetPlayerFromCharacter(tool.Parent) and tool.Parent or nil if not character then warn("Character not found") return end if typeof(model) == "Instance" then model:Destroy() end local Model = Instance.new("Model") Model.Parent = character local weld = Instance.new("WeldConstraint") weld.Parent = Model for _, part in tool:GetChildren() do if not part:IsA("BasePart") then continue end local new = part:Clone() new.Parent = Model new.Massless = true if part.Name == "Handle" then Model.PrimaryPart = new end end if Model.PrimaryPart then local lefthand: BasePart = character:FindFirstChild("LeftHand") if lefthand then Model.PrimaryPart.CFrame = lefthand.CFrame weld.Part0 = Model.PrimaryPart weld.Part1 = lefthand weld.Enabled = true else warn("LeftHand not found in character") end else warn("PrimaryPart not set in model") end model = Model return Model end tool.Equipped:Connect(function() Modelise() end) tool.Unequipped:Connect(function() if model then model:Destroy() model = nil end end)