Hello! Ive been trying to get something to work with Lineforces but i cant quite get it to work.
What I am trying to achieve is to where once an ability is activated for the tool it will pull whoever touches a box to you. Ive gotten it to work with lineforces but it doesnt pull them exactly to the player, it just pulls them with Magnitude. Is there any way you can use a players position to decrease or increase magnitude?
This is my script:
if script.Disabled == false then
script.Parent.PullBox1.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("HumanoidRootPart") then
local CharHRP = script.Parent.Parent:FindFirstChild("HumanoidRootPart")
local HRP = hit.Parent:FindFirstChild("HumanoidRootPart")
local att = Instance.new("Attachment")
att.Parent = HRP
att.Name = "black"
local att2 = Instance.new("Attachment")
att2.Parent = CharHRP
att2.Name = "black2"
local line = Instance.new("LineForce")
line.Visible = false
line.ApplyAtCenterOfMass = false
line.ReactionForceEnabled = false
line.InverseSquareLaw = false
line.Attachment0 = HRP.black
line.Attachment1 = CharHRP.black2
line.Magnitude = 35555
line.Parent = CharHRP
script.Disabled = true
wait(0.1)
script:Destroy()
line:Destroy()
att:Destroy()
att2:Destroy()
else if not hit.Parent:FindFirstChild("HumanoidRootPart") then
script.Disabled = true
script:Destroy()
end
end
end)
wait(0.1)
script:Destroy()
end
Thanks in advance!