Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

AutowedgeCells isn't working for me?

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)

2 answers

✓ Accepted answer
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?

2 comments

0

Oh yeah, that explains it all actually. I meant to put origin instead of mosPos.p in the Region3Int16. Thanks!

0

Well it's still broken but I think I know where to go from here. Thanks a ton.

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)


6 comments

0

What exactly did you change?

0

did it work?

0

It still does nothing, you gave me the exact same code I originally posted.

0

no i didnt try it agian and try using diffrent scripts like scripts and local scripts

0

This is in a plugin, it doesn't have local scirpts or scripts, it's simply a Main.lua file. I see nothing different about the code you posted, and it doesn't work any better either.

0

ugh you must be blind this should be working like a script rather than a plug in

This discussion is preserved as it was. New answers, comments, and votes are closed.