Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to weld part front of the player?


local attack = true

script.Parent.Activated:Connect(function()
    local char = script.Parent.Parent
    local torso = char:WaitForChild('HumanoidRootPart')
    
    if attack == true then
        attack = false
        print("activated")
        local part = Instance.new("Part",game.workspace.hitboxes)
        part.CFrame = torso.CFrame + (torso.CFrame.lookVector*5)
        part.Name = "hitboxpart"
        part.Size = Vector3.new(7,7,7)
        part.Anchored = true
        part.CanCollide = false
        part.Transparency = 0.5
		wait(0.4)
	end
end

This script creates a part front of the player but its not following the player. How can i make it follow, with weld or something else?

1 answer

Use WeldConstraint when doing this sometimes. Put Part0 as the part and Part1 as the HumanoidRootPart. Also make sure that the part is unanchored.

local attack = true

script.Parent.Activated:Connect(function()
    local char = script.Parent.Parent
    local torso = char:WaitForChild('HumanoidRootPart')

    if attack == true then
        attack = false
        print("activated")
        local part = Instance.new("Part",game.workspace.hitboxes)
        part.CFrame = torso.CFrame + (torso.CFrame.lookVector*5)
        part.Name = "hitboxpart"
        part.Size = Vector3.new(7,7,7)
        part.Anchored = false
        part.CanCollide = false
        part.Transparency = 0.5
        local Weld = Instance.new("WeldConstraint")
        Weld.Parent = part
        Weld.Part0 = part
        Weld.Part1 = torso
        wait(0.4)
    end
end

This should work, and if it doesn't, let me know in comments and I'll try to fix it.

Happy to help, b_mni.

This discussion is preserved as it was. New answers, comments, and votes are closed.