i am trying to make this Random Terrain Maker Plugin but the every time i run the plugin button it seems to not work!.
Error name:
user_C:/Users/U1/Downloads/IDK.rbxmx.Folder.Main:51: invalid 'for' limit (number expected, got nil)
My Code:
local Maingui = script.Parent.ScreenGui.MainFrame
local plugbutton = plugin:CreateToolbar("N/A"):CreateButton("N/A","N/A","N/A")
local ScreenGui = script.Parent.ScreenGui
local X_Button = Maingui.Topbar.Exit_Program
local Create_Terrain_Button = Maingui.Create
local INPUTS = Maingui.Inputs
local MapX = INPUTS.MXS
local MapY = INPUTS.MYS
local MapZ = INPUTS.MZS
local NS = INPUTS.NS
local MapX2 = tonumber(INPUTS.MXS)
local MapY2 = tonumber(INPUTS.MYS)
local MapZ2 = tonumber(INPUTS.MZS)
local NS2 = tonumber(INPUTS.NS)
isOn = false
ScreenGui.Parent = game.CoreGui
Maingui.Active = true
Maingui.Selectable = true
Maingui.Draggable = true
-- Terain Maker Main Code
function TerrainMaker(X,Y,Z,noisescale)
local Folder = Instance.new('Folder',game.Workspace)
Folder.Name = "TerrainFolder"
wait(0.5)
local mapxsize = X
local mapysize = Y
local mapzsize = Z
local seed = math.random(1,100000)
local noisescale = noisescale
local amp = 15
local psize = 2
for x=0,mapxsize do -- This is Where i get the Error!
for z=0,mapzsize do
for y=0,mapysize do
local xnoise = math.noise(y/noisescale,z/noisescale,seed)*amp
local ynoise = math.noise(x/noisescale,z/noisescale,seed)*amp
local znoise = math.noise(x/noisescale,y/noisescale,seed)*amp
local density = xnoise+ynoise+znoise+y
if density < 20 and density > 15 then
local part = Instance.new("Part",workspace.TerrainFolder)
part.Anchored = true
part.Size = Vector3.new(psize,psize,psize)
part.CFrame = CFrame.new(x*psize,y*psize,z*psize)
if part.Position.Y >= 59 then
part.BrickColor = BrickColor.new("Medium stone grey")
part.Material = ("SmoothPlastic")
else
part.BrickColor = BrickColor.new("Bright green")
part.Material = ("Grass")
end
end
end
end
wait(0.5)
end
end
Create_Terrain_Button.MouseButton1Click:Connect(function()
if MapX.Text == "" or MapY.Text == "" or MapZ.Text == "" or NS.Text == "" then
print("Please Provide all information Needed!")
else
TerrainMaker(MapX2,MapY2,MapZ2,NS2)
end
end)
plugbutton.Click:Connect(function()
isOn = not isOn
plugbutton:SetActive(isOn)
ScreenGui.Enabled = isOn
end)
any Reason why?
INPUTS.MXS,INPUTS.MYS,INPUTS.MZS are text box's
Is there a Way to fix my code?

8 comments
INPUTS.MXS,INPUTS.MYS,INPUTS.MZS are text box's
How do you expect to create numbers out of an object?
A for loop
That didn't answer my question
tonumber() converts strings into a numbers, but only if the string is 100% numbers
yes the input i give it is 100%numbers
There's a difference between an TextBox and the text inside of a TextBox
so how would you fix my code?