#Bezier curve script

19 messages · Page 1 of 1 (latest)

sharp tusk
#

i am new to scripting and i was following a tutorial and i am pretty sure i did what he said but i can't seem to get it working, could anyone please help me figure out what is wrong with this?

function lerp(a, b, c)
    return a + (b - a) * c
end

function quadBezier(t, p0, p1, p2)
    local l1 = lerp(p0, p1, t)

    local l2 = lerp(p1, p2, t)

    local quad = lerp(l1, l2, t)

    return quad
end

local TweenService = game:GetService("TweenService")

local PointA = workspace.PointA
local PointB = workspace.PointB
local PointC = workspace.PointC

while true do
    local Folder = Instance.new("Folder")
    Folder.Parent = workspace

    local part = Instance.new("Part")
    part.Anchored = true
    part.Shape = "Ball"
    part.Color = Color3.fromRGB(255, 192, 1)
    part.Position = PointA.Position
    part.Size = Vector3.new(2, 2, 2)
    part.Material = "Neon"
    part.Parent = Folder
    
    task.wait(1)
    
    local numberValue = Instance.new("NumberValue")
    numberValue.Parent = Folder

    local connection
    connection = numberValue.Changed:Connect(function()
        part.CFrame = CFrame.new(quadBezier(numberValue.Value, PointA.Position, PointB.Position, PointC.Position))

        TweenService:Create(numberValue, TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out), {Value = 1}):Play()

        task.wait(1)

        if connection then
            connection:Disconnect()
        end

        Folder:Destroy()
    end)
end
#

the script is supposed to make a neon yellow ball follow a bezier curve

viscid girder
#

no errors?

#

nothin?

sharp tusk
#

it tells me there are no errors but it doesnt create the ball and make it follow the curve so idk 🤷‍♂️

dense coralBOT
#

studio** You are now Level 2! **studio

little iris
#

hey t is meant to be a decmial

#

from 0 to 1

#

like 0% to 100%

#

down the path

#
for i = 0, 1, 0.1 do
-- this is a way of getting a decimal between 0 - 1
print(i)
end
#

it would print:

#

0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
0.9
1

#

the t in the beizer curve formula is the percentage in decimals

#

if its 0.9 it will be near the end and if its 0 it will be at the start

#

you never change the numbervalue.Value

#

@sharp tusk

#
for i = 0, 1, 0.1 do
-- this is a way of getting a decimal between 0 - 1
print(i) -- 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1
quadBeizer(i, ...) --this is how i did it the ... is a filler
end
sharp tusk
#

oh thank you 🙏