Player freezes on weld

So, i have combat system, and when player fires LMB event it plays sound and adds slash vfx to the workspace and welds it to player’s hrp, when it welds player freezes and unlags after 0.5-1 second?

Without this line of code, everything is ok:
slash.WeldConstraint.Part0 = hrp

Slash part’s properties is:
CanCollide = false
CanQuery = false
CanTouch = false
Anchored = false
Massless = true

Full slash function:

local function slash(character)
	if workspace:FindFirstChild("Slash") then
		return
	else
		
	local slash = ReplicatedStorage.VFX.Weapons.Staff.Slash:Clone()
	local hrp = character:FindFirstChild("HumanoidRootPart")
	
	slash.Parent = workspace
	slash.CFrame = hrp.CFrame

	--The issue:
	--slash.WeldConstraint.Part0 = hrp

	local startOrientation = slash.Orientation
	local endOrientation = startOrientation + Vector3.new(0, -390, 0)
	local tween = TweenService:Create(
		slash, 
		TweenInfo.new(0.5), 
		{Orientation = endOrientation}
	)

	tween:Play()
	tween.Completed:Connect(function()
		slash:Destroy()
	end)
	end
end

Slash influences mass and replication of a character likely.
It has to have massless property enabled and to be played locally for each player instead of server.

1 Like

Thanks!

Why you prefer UnreliableRemoteEvent over RemoteEvent?

It doesn’t have validation checks and is generally better for non important information.

1 Like