Line Force located inside of the Character’s Primary Part (Humanoid Root Part) works as it supposed to but after first use somewhy start to tweak and move the character slightly to the side.
(if u set magnitude like to 500 you can see that character is actually rotation around itself)
I do not know why is it happening
Demonstration of what i mean:
The script:
local RP = game:GetService("ReplicatedStorage")
local function LoadGear(Character,GivenParent)
local localODMGear = RP.ODM.Gear:Clone()
localODMGear.Parent = GivenParent
localODMGear.Name = Character.Name
localODMGear.Model.LeftHook.Weld.Part1 = Character.PrimaryPart
localODMGear.Model.RightHook.Weld.Part1 = Character.PrimaryPart
return localODMGear
end
local function GetMass(Model)
local mass = 0
for i, v in pairs(Model:GetChildren()) do
if v:IsA('BasePart') or v:IsA('Union') then
mass = mass + v:GetMass()
end
end
return mass
end
_G.HookMaxDistance = 75
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
Character.PrimaryPart = Character:WaitForChild("HumanoidRootPart")
local localODMGear = LoadGear(Character,workspace.GlobalPlayersGear)
local LeftHookBeam = localODMGear.Model.LeftHook.Beam
local LeftHookHitbox = localODMGear.Model.LLHP
local LeftHookOn = Instance.new("Attachment",LeftHookHitbox)
LeftHookOn.Name = "LeftHookOn"
local RightHookBeam = localODMGear.Model.RightHook.Beam
local RightHookHitbox = localODMGear.Model.LRHP
local RightHookOn = Instance.new("Attachment",RightHookHitbox)
RightHookOn.Name = "RightHookOn"
local PlayerMass = GetMass(Character)
--Ignore everything up here ^^^, all important stuff is down below
local VA = Instance.new("Attachment", Character.PrimaryPart)
VA.Name = "VectorAttachment"
VA.WorldPosition = Character.PrimaryPart.AssemblyCenterOfMass
local LHF = Instance.new("LineForce", Character.PrimaryPart)
LHF.Name = "LeftHookForce"
LHF.Enabled = false
LHF.ApplyAtCenterOfMass = false
LHF.Attachment0 = VA
LHF.Magnitude = PlayerMass * 50
local RHF = Instance.new("LineForce", Character.PrimaryPart)
RHF.Name = "RightHookForce"
RHF.Enabled = false
RHF.Attachment0 = VA
RHF.Magnitude = PlayerMass * 50
end)
end)
RP.ODM.LeftHook.OnServerEvent:Connect(function(Player, Status, MousePos, Distance)
if Distance > _G.HookMaxDistance then
Player:Kick("Detected suspicious movement")
end
local localODMGear = workspace.GlobalPlayersGear:FindFirstChild(Player.Name)
local LHF = Player.Character.PrimaryPart:FindFirstChild("LeftHookForce")
local LeftHookHitbox = localODMGear.Model.LLHP
local LeftHookOn = LeftHookHitbox:FindFirstChild("LeftHookOn")
if Status then
LHF.Enabled = true
LHF.Attachment1 = LeftHookOn
else
LHF.Enabled = false
end
end)
game.Players.PlayerRemoving:Connect(function(Player)
game.Debris:AddItem(workspace.GlobalPlayersGear:FindFirstChild(Player.Name))
end)
From what i tried to do to fix this is - Setting attach0 and attach1 to nil, disabling the line force, destroying line force with :destroy() and debris.
Appreciate any help