I want to limit the math random for a motor desired, This is a wait script whichw ill will operate mathrandon run
However, i want to limit the Motor6D Desiredangle between 0.03 & 0.07, But i get this error:
18:52:38.212 - Workspace.Plane.Parts.WNGF_Model.HighAltitude_Wingflex:18: bad > argument #1 to 'random' (interval is empty) 18:52:38.212 - Stack Begin 18:52:38.213 - Script 'Workspace.Plane.Parts.WNGF_Model.HighAltitude_Wingflex', Line 18 18:52:38.213 - Stack End
b = script.Parent.Parent.Engine wingflex = script.Parent.Parent.Wings_Motion --LeftWingCenter.A.Motor.DesiredAngle = (math.random(MinimumFlex,MaximumFlex LeftWingCenter = wingflex.Left.Outboard RightWingCenter = wingflex.Right.Outboard local MotorAngle = (0.03/0.07) while wait(0.009) do if b.Position.Y > 1 and b.Position.Y < 9999 then print('WingFlexing') LeftWingCenter.A.Motor.MaxVelocity = 0.005 RightWingCenter.A.Motor.MaxVelocity = 0.005 for x = 0.1,1 do wait(math.random(1,2)) print('WingFlex Motion 1') LeftWingCenter.A.Motor.DesiredAngle = (math.random(MotorAngle)) RightWingCenter.A.Motor.DesiredAngle = (math.random(MotorAngle)) end end end
randomNum =math.random (3,7) *.01 0 Also for math.random() you need two numbers. on lines 18 and 19 you have 1 number only
There was an error in the index table at line 17 heres a fix
Part = {} --This is a table where your part instance will go when it's created. Part.__index = Part --metamethod, that creates variables for you when you're referring to a variable and it doesn't exist. don't have to worry about what this line does really. --by calling this function (called a constructor function), you will make a new part object/instance call this function by saying: myPart = Part.new() function Part.new(position) local newPart = {} setmetatable(newPart, Part) newPart.Transparency = 0 newPart.Position = position --if you specified a position, you can set the part's position variable here return newPart --returns the part instance you just made into myPart variable end --a method for the part class. you can call this by saying Part:SetTransparency(newTransparency) function Part:SetTransparency(newTransparency) self.Transparency = newTransparency --This is where self comes in. the INSTANCE's transparency variable is set to the new transparency. end