robloxapp-20231130-2307547.wmv (1.3 MB)
Yeah… I think there’s a problem with my code…
The bottle went behind the targeted character instead of going between the characters from start-end
Did I get the math wrong?
local function lerp(a,b,c)
return a + (b - a) * c
end
function quadBezier(p0, p1, p2, t)
local l1 = lerp(p0, p1, t)
local l2 = lerp(p1, p2, t)
local quad = lerp(l1, l2, t)
return quad
end
local function throw(EnemyHumanoidRootPart)
local start = Bot.HumanoidRootPart.Position + Vector3.new(0,0,3)
local finish = EnemyHumanoidRootPart.Position + Vector3.new(0,-2,0)
local middle = (finish - start) + Vector3.new(0,30,0)
local molotov = Bot["Right Arm"].Molotov:Clone()
molotov.Transparency = 0
molotov.Cloth.Transparency = 0
molotov.Cloth.Fire.Enabled = true
molotov.Anchored = true
molotov.Parent = workspace
for i = 1, 100 do
local t = i/100
local updated = quadBezier(start,middle,finish,t)
molotov.Position = updated
local part = Instance.new("Part")
part.Anchored = true
part.CanCollide = false
part.CanQuery = false
part.Size = Vector3.new(0.1,0.1,0.1)
part.Parent = workspace
part.Position = updated
debris:AddItem(part, 5)
wait()
end
molotov:Destroy()
end