How can I extend the scale of this sine wave?

I just came up with a small script to animate a sine wave. It works fine, but, I figured extending the amount of parts involved would essentially ‘detail’ the sine wave more, but instead the sine wave just replicates itself.

What it does:

The code:

local array = {}
local gamestarted = tick()
for i = 1,20 do
	local part = Instance.new("Part")
	part.Position = Vector3.new(i,0,0) + Vector3.new(0,5,0)
	part.Size = Vector3.new(1,1,1)
	part.Anchored = true
	part.Parent = workspace.Parts
	table.insert(array, part)
end

while wait() do
	for index, part in pairs (array) do
		part.Position = Vector3.new(part.Position.X, 5, part.Position.Z) + Vector3.new(0, math.sin(tick() - gamestarted + index) / 2, 0)
	end
end

What I want:

The sine wave to instead utilize all the parts to generate the length of 1 wave

1 Like

try multiplying it to increase the wave

That just increases the intensity of it.

1 Like
local array = {}
local gamestarted = tick()
for i = 1,90 do -- size of wave
	local part = Instance.new("Part")
	part.Position = Vector3.new(i,0,0) + Vector3.new(0,5,0)
	part.Size = Vector3.new(1,1,1)
	part.Anchored = true
	part.Parent = workspace.Parts
	table.insert(array, part)
end

while wait() do
	for index, part in pairs (array) do
		part.Position = Vector3.new(part.Position.X, 5, part.Position.Z) + Vector3.new(0, math.sin(tick() - gamestarted + index) / 2, 0)
	end
end

I’m looking to increase the amount of parts used on a singular sine wave, this just creates more sine waves based on the amounts of parts.

try changing the increment to a smoler amount such as 0.1

2 Likes
for i = 1,20 do --to
for i = 1,20 ,0.1 do

A sine wave has this generic math equation:

y = A * sin(x + vt) + C

A is amplitude. v is an offset. C is a constant.

2 Likes

Hey is it ok if I use your code for practice, I wont make my game public

local array = {}

local gamestarted = tick()

for i = 1,90 do -- size of wave

local part = Instance.new("Part")

part.Position = Vector3.new(i,0,0) + Vector3.new(0,45,0)

part.Size = Vector3.new(1,1,1)

part.Anchored = true

part.Parent = workspace.Parts

table.insert(array, part)

end

while wait() do

for index, part in pairs (array) do

part.Position = Vector3.new(part.Position.X, 45, part.Position.Z) + Vector3.new(0, math.sin((tick() - gamestarted + index / 10)) * 8, 0)

end

end