Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Interestingly, this module script is refusing to acknowledge it's own functions?

Le module in question:






local BezierCurve = {}

function BezierCurve.Linear(Percent,P0,P1,Ins,Property)
	local t = Percent/100
	t = t >= 1 and 1 or t
	if P0 and P1 then
		if Ins and Ins[Property] then
			if Property == "CFrame" then
				local P0 = P0.p
				local P1 = P1.p
				Ins[Property] = CFrame.new(P0 + t * (P1-P0))
			else
				Ins[Property] = P0 + t * (P1-P0)
			end
		else
			return P0 + t * (P1-P0)
		end
	end
end

function BezierCurve.Quadratic(Percent,P0,P1,P2,Ins,Property)
	local t = Percent/100
	t = t >= 1 and 1 or t
	if P0 and P1 and P2 then
		if Ins and Ins[Property] then
			if Property == "CFrame" then
				local P0 = P0.p
				local P1 = P1.p
				local P2 = P2.p
				Ins[Property] = CFrame.new((1-t)^2 * P0 + 2 * (1-t) * t * P1 + t^2 * P2)
			else
				Ins[Property] = (1-t)^2 * P0 + 2 * (1-t) * t * P1 + t^2 * P2
			end
		else
			return (1-t)^2 * P0 + 2 * (1-t) * t * P1 + t^2 * P2
		end
	end
end

function BezierCurve.Cubic(Percent,P0,P1,P2,P3,Ins,Property)
	local t = Percent/100
	t = t >= 1 and 1 or t
	if P0 and P1 and P2 and P3 then
		if Ins and Ins[Property] then
			if Property == "CFrame" then
				local P0 = P0.p
				local P1 = P1.p
				local P2 = P2.p
				local P3 = P3.p
				Ins[Property] = CFrame.new((1-t)^3 * P0 + 3 * (1-t)^2 * t * P1 + 3 * (1-t) * t^2 * P2 + t^3 * P3)
			else
				Ins[Property] = (1-t)^3 * P0 + 3 * (1-t)^2 * t * P1 + 3 * (1-t) * t^2 * P2 + t^3 * P3
			end
		else
			return (1-t)^3 * P0 + 3 * (1-t)^2 * t * P1 + 3 * (1-t) * t^2 * P2 + t^3 * P3
		end
	end
end

function BezierCurve.Interp(Method,StartPercent,DesiredPercent,Duration,Callback,...)
	local Start = tick()
	local EndTime = Start + Duration
	local PercentDif =  DesiredPercent - StartPercent
	while tick() < EndTime do
		wait()
		local NewPercent = StartPercent + PercentDif * ((tick()-Start)/Duration)
		if Method == "Linear" then
			BezierCurve.Linear(NewPercent,...)
		elseif Method == "Quadratic" then
			BezierCurve.Quadratic(NewPercent,...)
		elseif Method == "Cubic" then
			BezierCurve.Cubic(NewPercent,...)
		end
	end
	if Callback then
		Callback()
	end
end
return BezierCurve



When require()'d and I attempt to use BezierCurve.Interp() from any other script, it returns the error 'Interp is not a valid member of ModuleScript'. Have I just missed something with syntax and I'm too fried to tell? Example:

BezierCurves.Interp("Quadratic", 0, 100, 2, 0, P1, P2, P3, Grenade, "CFrame")

2 comments

0

Please edit your question to also include where you define the variable BezierCurves, because your problem lies in your usage, not in the actual module.

0

Where you define it in a normal script*

1 answer

You problem lies in the fact that you did not require the module correctly. Try adding this code into your script before attempting to use a function from the module.

local BezierCurves = require() -- Module location here

If my answer solved you problem, please don't forget to mark it as right.

2 comments

0

I have require()'d it. I stated this.

0

You didnt include the line that require()s it. I wasnt sure if you made it a variable properly

This discussion is preserved as it was. New answers, comments, and votes are closed.