I've set up this simple plugin, and what it should do is smooth a radius of terrain around where the mouse is pointed at. It print 'Click', but doesn't smooth.
local plugin = PluginManager():CreatePlugin() local toolbar = plugin:CreateToolbar("Hello World Plugin") local terrain = Game.Workspace.Terrain local smoothButton = toolbar:CreateButton( "Smooth", "Use this to smooth an area of terrain", "SmoothIcon.png" ) smoothButton.Click:connect(function() plugin:Activate(true) local mouse=plugin:GetMouse() mouse.Button1Down:connect(function() local mosPos = mouse.Hit local origin = terrain:WorldToCell(mosPos.p) local Radius = 4 local region = Region3int16.new(Vector3int16.new(Vector3.new(-Radius,-Radius,-Radius) + mosPos.p), Vector3int16.new(Vector3.new(Radius,Radius,Radius) + mosPos.p)) terrain:AutowedgeCells(region) print('Click') end) end)
local plugin = PluginManager():CreatePlugin() local toolbar = plugin:CreateToolbar("Hello World Plugin") local terrain = Game.Workspace.Terrain local smoothButton = toolbar:CreateButton( "Smooth", "Use this to smooth an area of terrain", "SmoothIcon.png" ) smoothButton.Click:connect(function() plugin:Activate(true) local mouse=plugin:GetMouse() mouse.Button1Down:connect(function() local mosPos = mouse.Hit local origin = terrain:WorldToCell(mosPos.p) local Radius = 4 local region = Region3int16.new(Vector3int16.new(Vector3.new(-Radius,-Radius,-Radius) + mosPos.p), Vector3int16.new(Vector3.new(Radius,Radius,Radius) + mosPos.p)) terrain:AutowedgeCells(terrain) -- He changed this line, which is calling a nil value. That won't work at all. print('Smooth') end) end)
I'm not an expert in terrain, although I hope to get better. Why do you declare origin, but never index it?
Try this
local plugin = PluginManager():CreatePlugin() local toolbar = plugin:CreateToolbar("Hello World Plugin") local terrain = Game.Workspace.Terrain local smoothButton = toolbar:CreateButton( "Smooth", "Use this to smooth an area of terrain", "SmoothIcon.png" ) smoothButton.Click:connect(function() plugin:Activate(true) local mouse=plugin:GetMouse() mouse.Button1Down:connect(function() local mosPos = mouse.Hit local origin = terrain:WorldToCell(mosPos.p) local Radius = 4 local region = Region3int16.new(Vector3int16.new(Vector3.new(-Radius,-Radius,-Radius) + mosPos.p), Vector3int16.new(Vector3.new(Radius,Radius,Radius) + mosPos.p)) terrain:AutowedgeCells(terrain) print('Smooth') end) end)