So I have this camera spring script, which goes into a module script. The thing is, I'm don't know how to call a function from a module script. I feel pretty stupid right now, but I seriously dunno. Here's the script.
local Spring = {}
Spring.__index = Spring
function Spring:Update(dt)
local t, k, d, x0, v0 = self.t, self.k, self.d, self.x, self.v
local a0 = k*(t - x0) + v0*d
local v1 = v0 + a0*(dt/2)
local a1 = k*(t - (x0 + v0*(dt/2))) + v1*d
local v2 = v0 + a1*(dt/2)
local a2 = k*(t - (x0 + v1*(dt/2))) + v2*d
local v3 = v0 + a2*dt
local x4 = x0 + (v0 + 2*(v1 + v2) + v3)*(dt/6)
self.x, self.v = x4, v0 + (a0 + 2*(a1 + a2) + k*(t - (x0 + v2*dt)) + v3*d)*(dt/6)
return x4
end
function Spring.new(stiffness, dampingCoeff, dampingRatio, initialPos)
local self = setmetatable({}, Spring)
dampingRatio = dampingRatio or 1
local m = dampingCoeff*dampingCoeff/(4*stiffness*dampingRatio*dampingRatio)
self.k = stiffness/m
self.d = -dampingCoeff/m
self.x = initialPos
self.t = initialPos
self.v = initialPos*0
return self
end
return Spring
Any help would be great.

7 comments
These formulas can be simplified my guy.
local m = (dampingCoeff ^ 2) / ((stiffness * 4) * ( dampingRatio ^ 2))
self.v is an unnecessary calculation too.
Mmm, thanks for the advice. But I still dunno how to call functions from a module script. Do I need a remote function thing?
Spring.new(0,0,0,0):Update(0). The methods are bound to the class that it's created for, create an Instance of the Object and call the function. Use require() to include the Object in another script.
It's also best you don't write these variables in an algebraic form. Try to give them names that correlate to it's purpose. It'll help you in the future.
Okay, thanks. I'm trying some stuff out rn