So I made this script and I keep the a error saying bad cast,what does it mean and how could I fix it? If you manged to fix it please show how and what you did.
Error:
bad cast
Script 'Workspace.Model.Script', Line 11
Stack End
--~-----------Vairbles---------------~--
local Model = script.Parent
---------------------------------------------
for Number,Part in pairs (Model:GetChildren()) do
--------------More Vairbles----------------
local PreviousPart = math.floor(Number - 1)
local PreviousPartName = "Part"..PreviousPart
local Motor = Instance.new("Motor6D",Part)
-------------------------------------------
print(PreviousPartName)
Motor.Part0 = Part
Motor.Part1 = Model.PreviousPartName
print(Motor.Part0)
Motor.DesiredAngle = -Number
end
The model is set up like this:

2 comments
A cast in programming means a type conversion. A bad cast in this case means you are trying to convert a type in a wrong way.
How can I convert it in the right way?