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