So my friend Max loves to script, so I made this model for him. This is the only script inside and there is something wrong. The problem is at Line 26. I need help figuring it out!
local function newpart() local boss = script.Parent.Parent --The model that the script is inside local newPart = Instance.new("Part", game.Workspace) newPart.Position = script.Parent.Parent.PlaceHolder.Position newPart.Anchored = false --So that the part falls out of the machine local x = math.random(1,7) local y = math.random(1,7) local z = math.random(1,7) newPart.Size = Vector3.new(x,y,z) boss.SizeX.SurfaceGui.TextLabel.Text = "Size: "..x..", "..y..", "..z --Size newPart.BrickColor = BrickColor.Random() boss.BrickColorX.SurfaceGui.TextLabel.Text = "Color: "..newPart.BrickColor.Name --Color local tr = math.random(100,1000) tr = tr / 1000 newPart.Transparency = tr boss.TransparencyX.SurfaceGui.TextLabel.Text = "Transparency: "..newPart.Transparency --Transparency local m = math.random(1,21) local ml = {"Brick","Cobblestone","Concrete","CorrodedMetal","DiamondPlate","Fabric","Glass","Granite","Grass","Ice","Marble","Metal","Neon","Pebble","Plastic","Sand","Slate","SmoothPlastic","Wood","WoodPlanks"} local mlm = ml[m] newPart.Material = mlm boss.MaterialX.SurfaceGui.TextLabel.Text = "Material: "..mlm --Material local s = math.random(1,3) if s == 1 then newPart.Shape = Enum.PartType.Block s = "Block" elseif s == 2 then newPart.Shape = Enum.PartType.Ball s = "Ball" elseif s == 3 then newPart.Shape = Enum.PartType.Cylinder s = "Cylinder" end boss.ShapeX.SurfaceGui.TextLabel.Text = "Shape: "..s wait(10) local newTool = Instance.new("Tool") newTool.CanBeDropped = true newTool.Name = "Part" newPart.Parent = newTool newTool.RequiresHandle = true newPart.Name = "Handle" newTool.Parent = game.Workspace newTool.ToolTip = s..", Color: "..newPart.BrickColor.Name..", Size: "..x..", "..y..", "..z end while true do newpart() end
The problem is not in Line 25, the line just got cut off because of limited space.
If this answer helped you please make sure you accept it!
The only problem is see is that your math.random has a maximum of 21, but you only added 20 materials. Try changing the m to math.random(1,20).