As the title say’s whenever I locally weld something to the player it flings them. This is a problem I encountered when trying to do Client Sided Replication or making VFX on the client. It flings the character or moving/rotating it.
It can be shown in this video:
I decided to disable the knockback (It uses Linear Velocity) and figured out that there’s no issue with the knockback turned off.
Shown Here:
So now the problem is finding a way for the 2 to combine with each other without flinging. I’ll send the code that I wrote for these scripts and how I’m using it.
The Linear Velocity System is Setup like this:
local HRP = Character.HumanoidRootPart
local Humanoid = Character:FindFirstChildOfClass("Humanoid")
-- Ensure we have a RootAttachment
local rootAttachment = HRP:FindFirstChild("RootAttachment")
if not rootAttachment then
rootAttachment = Instance.new("Attachment")
rootAttachment.Name = "RootAttachment"
rootAttachment.Parent = HRP
end
local LinearVelocity = Instance.new("LinearVelocity")
LinearVelocity.Attachment0 = rootAttachment
LinearVelocity.MaxForce = math.huge
LinearVelocity.VectorVelocity = Direction.Unit * Distance
LinearVelocity.Parent = HRP
-- Whenever I need to stop I'll destroy it LinearVelocity:Destroy()
And The VFX Script is used like this:
-- Parent the VFX
if Parent and Parent.Parent then
clonedVFX.Parent = Parent
else
-- Create ClientFX folder if it doesn't exist
if not workspace:FindFirstChild("ClientFX") then
local clientFX = Instance.new("Folder")
clientFX.Name = "ClientFX"
clientFX.Parent = workspace
end
clonedVFX.Parent = workspace.ClientFX
end
-- Handle welding
if ShouldWeld and Parent and Parent.Parent then
local offsetCFrame = Position * Orientation
local weld = createWeldConstraint(Parent, clonedVFX, offsetCFrame)
-- Clean up weld after duration
if Duration and Duration > 0 then
Debris:AddItem(weld, Duration)
end
else
-- If not welding, just position the VFX
if Parent and Parent.Parent then
clonedVFX.CFrame = Parent.CFrame * Position * Orientation
end
end
-- Yes before that I disable Anchored, CanCollide, etc.