Tool's welded part glitches when equipped

I have a sword that plays a hold animation when a player equips and and a attack animation when a player clicks, but when I add a hitbox, the player starts glitching out along with the tool. Both parts have can collide and anchored to false.

Script:

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local tool = script.Parent
local hold = tool:FindFirstChild('Hold')
local attack = tool:FindFirstChild('Attack')
local animationtrack = char:WaitForChild('Humanoid').Animator:LoadAnimation(hold)

tool.Equipped:Connect(function()
	animationtrack.Looped = true
	animationtrack:Play()
end)

tool.Unequipped:Connect(function()
	animationtrack:Stop()
end)

tool.Activated:Connect(function()
	animationtrack:Stop()
	local animationattack = char:WaitForChild('Humanoid').Animator:LoadAnimation(attack)
	animationattack:Play()
	wait(0.78)
	local clone = game.ReplicatedStorage.SwordHitbox:Clone()
	clone.Parent = tool
	clone.CanCollide = false
	clone.Anchored = false
	clone.Transparency = 1
	local weld = Instance.new('WeldConstraint', tool.Handle)
	weld.Part0 = tool.Handle
	weld.Part1 = clone
	tool["Sword Swing Metal Heavy"]:Play()
	
	animationattack.Stopped:Wait()
	clone:Destroy()
	animationtrack:Play()
end)


Video:
robloxapp-20230517-1644192.wmv (2.1 MB)

Screenshot of tool:

Make sure the hitbox has massless enabled in its properties. When a part with mass is held by the player it can weigh the character down and cause glitching; regardless of whether or not it’s invisible.

Programmatically, you could simply do clone.Massless = true.

Also, another note, you shouldn’t assign parents using the second argument of Instance.new(); it is deprecated and can lead to weird behavior (especially if they remove the feature).

Here is Roblox staff talking about not using the second argument:

Hope this helps! :slight_smile:

1 Like

Woah! Didn’t know mass could cause this! Thanks for the help.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.