hello all, I am trying to use OOP for the first time and doing some tests, in this example some simple animations for grass. I know its super messy and doesn’t look like properly moving grass at the moment but its just for testing purposes rn.
server script VVVV
local replicated = game:GetService("ReplicatedStorage")
local grassFolder = script.Parent
local grass = require(script.Grass)
for i,v in pairs(grassFolder:GetChildren()) do
if v:IsA("BasePart") then
coroutine.wrap( grass.new(v))
end
end
Module script VVVV
local maxRot = 30
local grass = {}
function grass.new(blade)
if blade.Position then
local origin = {
position = blade.Position,
orientation = blade.Orientation
}
grass.move(blade,origin)
end
end
function grass.move(blade, origin)
while wait(.5) do
local newRot = origin.orientation + Vector3.new(math.random(0,maxRot),math.random(0,maxRot),math.random(0,maxRot))
for i = 1, 10 do
wait(.1)
blade.Orientation = (newRot)*(i/10)
end
end
end
return grass
it currently only animates one blade of grass, even after i tried the coroutine but if someone could tell me what im doing wrong and how to avoid it in future?