Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How do you weld an object to the character without causing movement issues?

Asked by 3 years ago

I'm trying to create a melee weapon with a "damage radius" around the player. The welding however, causes the player to glitch out every time I use the weapon. Any help?

    local DamageObject = Instance.new("Part")
    DamageObject.Parent = workspace
    DamageObject.Name = Player.Name.."'s DamageObject"
    DamageObject.Shape = Enum.PartType.Ball
    DamageObject.Anchored = false
    DamageObject.CanCollide = false
    DamageObject.Size = Vector3.new(10, 10, 10)
    DamageObject.Position = workspace[Player.Name].UpperTorso.Position

    local weld = Instance.new("Weld")
    weld.Parent = DamageObject
    weld.Name = "Weld"
    weld.Part0 = workspace[Player.Name].LowerTorso
    weld.Part1 = DamageObject
    weld.C0 = workspace[Player.Name].UpperTorso.CFrame:Inverse()
    weld.C1 = DamageObject.CFrame:Inverse()

    DamageObject.Touched:Connect(function(Part)
        local Humanoid = Part.Parent:FindFirstChild("Humanoid")
        if Part.Parent:FindFirstChild("Humanoid") and table.find(IgnoreList, Part.Parent.Name) == nil then      
            if Part.Parent:FindFirstChild("Died") == nil then
                ReplicatedStorage.DamageEvent:Fire(Player, Part.Parent.Humanoid, 25)
                table.insert(IgnoreList, 1, Part.Parent.Name)
            end

            if Humanoid.Health <= 0 then
                local DeathMarker = Instance.new("Folder")
                DeathMarker.Name = "Died"
                DeathMarker.Parent = Part.Parent
            end
        end
    end)

    wait(0.5)
    DamageObject:Destroy()
    IgnoreList = {}

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

you could make the part massless, i have done that before it works.

part.Massless = true
0
Thank you! R0B0T_K1LLER 0 — 3y
Ad

Answer this question