Hi all.
I was thinking of ways to automate this… i’ll let my script speak for me.
I know it’s ugly but that is why i’m here.
local RunService = game:GetService("RunService")
local function GetTouchingParts(part)
local connection = part.Touched:Connect(function() end)
local results = part:GetTouchingParts()
connection:Disconnect()
return results
end
RunService.Heartbeat:Connect(function()
--important part
local pos = script.Parent.Bullet.Position
local targ = script.Parent.Physics.Position
local avg4 = (targ + pos) / 2
local avg2 = (avg4 + pos) / 2
local avg6 = (avg4 + targ) / 2
local avg1 = (pos + avg2) / 2
local avg3 = (avg2 + avg4) / 2
local avg5 = (avg4 + avg6) / 2
local avg7 = (avg6 + targ) / 2
local PP = {}
PP[1] = avg1
PP[2] = avg2
PP[3] = avg3
PP[4] = avg4
PP[5] = avg5
PP[6] = avg6
PP[7] = avg7
PP[8] = targ
--important part
for i = 1, 8, 1 do
script.Parent.Bullet.Position = PP[i]
local Parts = GetTouchingParts(script.Parent.Bullet)
for j = 1, #Parts, 1 do
if Parts[j].Name ~= "Physics" then
script.Parent:Destroy()
end
end
end
end)
Automate.rbxl (22.0 KB)
On every Heartbeat
it divides the distance traveled by the physics
part
. How can i automate this? aka: Tell it how many times it should divide. (looks like it would lag but works perfectly)
Reasons why i did it like this (if you’rewondering), is that .Touched
is unreliable at high speeds, and Tween
and Lerp
just didn’t prove stable enough or right for the job.
Any help is appreciated!