I’m attempting to create a tool from a model, being the handle its PrimaryPart.
My current code is:
local model = IM.getModel(IM.get(item.ID)) -- This just gets the model
local handle = model.PrimaryPart:Clone()
handle.Name = "Handle"
handle.Anchored = false
handle.CanCollide = false
handle.Parent = tool
-- Loops the model and welds any non-primary part to the tool handle
for i, v in pairs(model:GetChildren()) do
if model.PrimaryPart ~= v then
local c = v:Clone()
c.Anchored = false
c.CanCollide = false
c.Parent = tool
local weld = Instance.new("Weld")
weld.Part0 = handle
weld.Part1 = c
weld.Parent = handle
end
end
return tool -- Code is inside a function
This code works fine when the Model only has one part, but when it has more than one, if the player equips the tool (I do it via humanoid:EquipTool(tool), from the client) it gets teleported to (I believe) somewhere near the original position of the handle.
The complete code process is:
Server creates welded tool -> Sends to player backpack -> Client equips from backpack to humanoid
I’m using humanoid:EquipTool(tool) on the client to equip the tool
I’ve been trying to search up a solution but I don’t really see my issue with the code, so I was thinking maybe you guys have any ideas?
Thanks a lot in advance!