#Help with Model to Tool

1 messages · Page 1 of 1 (latest)

marsh spindle
#

Hey so basically I have a script that converts a model into a tool, the tool is automatically equipped but the character ragdolls and I don't know how to fix it.

wind oak
#

could you send the code?

thin agateBOT
#

studio** You are now Level 1! **studio

marsh spindle
#

@wind oak

function Functions.ConvertToTool(Model: Model, Player: Player)
    local Tool = Instance.new("Tool", Player.Character)
    Tool.Name = Model.Name
    
    local Handle = Instance.new("Part")
    Handle.Name = "Handle"
    Handle.Size = Vector3.one
    Handle.Transparency = 1
    Handle.CanCollide = false
    Handle.Massless = true
    Handle.Anchored = false
    Handle.Parent = Tool
    
    local ModelClone = Model:Clone()
    local ModelCFrame = Model:GetPivot()
    
    ModelClone.Parent = Tool
    Handle.CFrame = ModelCFrame
    
    for _, v in ModelClone:GetDescendants() do
        if v:IsA("BasePart") or v:IsA("UnionOperation") or v:IsA("MeshPart") then
            v.Anchored = false
            v.CanCollide = false
            v.CanTouch = false
            v.Massless = true
            
            local Weld = Instance.new("WeldConstraint")
            Weld.Part0 = Handle
            Weld.Part1 = v
            Weld.Parent = Handle
        elseif v:IsA("ProximityPrompt") or v:IsA("BillboardGui") or v:IsA("Humanoid") or v:IsA("WeldConstraint") or v:IsA("Weld") then
            v:Destroy()
        end
    end
    
    return Tool
end