What is wrong with my script

What is wrong with my script? I cant seem to find the error

function script.Five.OnServerInvoke()
for i,v in pairs (game.Workspace.LXBeams:GetChildren()) do
if v.Name == “L1” then
v.Motors.Tilt.DesiredAngle = math.rad(45)
else if v.Name == “L2” then
v.Motors.Tilt.DesiredAngle = math.rad(41.25)
else if v.Name == “L3” then
v.Motors.Tilt.DesiredAngle = math.rad(37.5)
else if v.Name == “L4” then
v.Motors.Tilt.DesiredAngle = math.rad(33.75)
else if v.Name == “L5” then
v.Motors.Tilt.DesiredAngle = math.rad(30)
else if v.Name == “L6” then
v.Motors.Tilt.DesiredAngle = math.rad(26.25)
else if v.Name == “L7” then
v.Motors.Tilt.DesiredAngle = math.rad(22.5)
else if v.Name == “L8” then
v.Motors.Tilt.DesiredAngle = math.rad(18.75)
else if v.Name == “L9” then
v.Motors.Tilt.DesiredAngle = math.rad(15)
else if v.Name == “L10” then
v.Motors.Tilt.DesiredAngle = math.rad(11.25)
else if v.Name == “L11” then
v.Motors.Tilt.DesiredAngle = math.rad(7.5)
else if v.Name == “L12” then
v.Motors.Tilt.DesiredAngle = math.rad(3.75)
end
end
end

I have now fixed the issue i didn’t need a space between else and if

That’s a lot of elseifs, why not just making a dict with the names as keys and radians as values…?

1 Like