Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Terrain Editing Plugin Issue?

Asked by 10 years ago

Upon downloading and installing Anaminus's Better Brush, it generates a error, which I cannot seems to fix. The output from Studio is stated below:

18:37:50.394 - C:/Users/Chance/AppData/Local/Roblox/Plugins/BetterBrush/Be:10: attempt to index local 'Terrain' (a nil value)

The plugin icon exists, but is fully visible on the toolbar.

If anyone could tell me why it is throwing that error and a fix, i'd greatly appreciate it

Code snip below. First segment of 400 lines.

local Plugin = PluginManager():CreatePlugin()
local Toolbar = Plugin:CreateToolbar("Terrain")
local ActivateButton = Toolbar:CreateButton("", "Brush", "brush.png")
local Mouse = Plugin:GetMouse()

local plugin_loaded = false
local plugin_active = false

local Terrain = game.Workspace.Terrain
local SetCell = Terrain.SetCell
local SetCells = Terrain.SetCells
local GetCell = Terrain.GetCell
local AutowedgeCells = Terrain.AutowedgeCells
local WorldToCellPreferSolid = Terrain.WorldToCellPreferSolid

local MAX_HEIGHT = Terrain.MaxExtents.Max.Y

local brushRadius = 4
local maxBrushRadius = 16
local minBrushRadius = 1

local heightOffset = 0
local maxHeightOffset = 32
local minHeightOffset = -32

local brushMaterial = 1
local clearAbove = false
local fillBelow = true
local autoSmooth = true

local Region3i = Region3int16.new
local Vector3i = Vector3int16.new
local function R3(a,b,c,x,y,z)
    return Region3i(
        Vector3i(a,b,c),
        Vector3i(x,y,z)
    )
end
0
In contact with Anaminus for further assistance. chance9025 15 — 10y

1 answer

Log in to vote
0
Answered by
samfun123 235 Moderation Voter
10 years ago

I think the problem with this is that plugins load before anything else so when it tries to call the Terrain it is not there.

The solution is to using :WaitForChild("Terrain")

local Terrain = game.Workspace:WaitForChild("Terrain")

This would be the updated version of line 9

If you have any questions, concerns or just need some help with this PM me on ROBLOX!

0
Thank you for your answer! It eliminated the error from Studio, and the plugin opens, but it doesn't edit the terrain. I'll PM you on Roblox! chance9025 15 — 10y
Ad

Answer this question