# Sine wave script gives odd output

Edit:

``````-- Changed my sin function to
for i = equation[2], equation[3], 0.5 do
spawn(function()
local new_node = Instance.new("Part")
new_node.Size = Vector3.new(1,1,1)
new_node.Anchored = true
local x = (i)
local y = math.sin(i * math.pi/180) * equation[4]
new_node.Position = Vector3.new(x, y, 0)
new_node.Parent = equation_graph
end)
end
``````

I was trying to map out/graph a sin wave with Roblox by using parts as a representation. Linear and quadratic sequences all worked out fine. However, I got an interesting result of sin from this.

The script I used to generate this would be:

``````for i = equation[2], equation[3], 0.1 do
spawn(function()
local new_node = Instance.new("Part")
new_node.Size = Vector3.new(1,1,1)
new_node.Anchored = true
local x = (i)
local y = (math.sin(math.deg(i))) * equation[4]
print(x, y)
new_node.Position = Vector3.new(x, y, 0)
new_node.Parent = equation_graph
end)
end
``````

Iâ€™ve tried inspecting each of the partâ€™s to see whatâ€™s going on with them but I couldnâ€™t conclude anything from it. Anyone else got some suggestions?

What does your â€śequationâ€ť table look like?

I solved it but hereâ€™s all the equations Iâ€™m mapping out currently:

``````local equations = {
equation_solver.solve("linear", 1, 2),
equation_solver.solve("linear", 7, 15),
equation_solver.solve("linear", 6, 9),
{"sin", -180, 180, 10},
{"sin", -180, 180, 3},
{"sin", -180, 180, 1},
{"sin", -180, 180, 5},
{"sin", -180, 180, 100}
}
``````
1 Like

Nevermind, I see you changed the title to â€śSolved.â€ť Perhaps create a comment with your solution and then mark it as the solution.

``````local y = math.sin(math.deg(i))
``````local y = math.sin(i * math.pi/180)