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

What is this error, and how do I fix it?

Asked by 10 years ago

I am making a plugin that creates walls along the edges of the selected part, but it keeps coming out with this error:

108:10:43.551 - Plugin_191344304.MakeWalls.Script:50: bad argument #1 to '?' (Vector3 expected, got number)
208:10:43.552 - Script 'Plugin_191344304.MakeWalls.Script', Line 50
308:10:43.552 - Stack End
408:10:43.553 - Disconnected event because of exception

The code is here:

01local pluginVersion = 0.35
02local hasLoaded = plugin:GetSetting("pluginHasLoaded")
03print("Loading ExplosionCreate Plugin v" .. pluginVersion) --Just a loading message
04if not hasLoaded then
05    plugin:SetSetting("pluginHasLoaded", true)
06end
07 
08-- Setup Toolbar
09local toolbar = plugin:CreateToolbar("dudemanloserr Productions") --Toolbar Name
10local isActive = false
11-- Setup button
12local button = toolbar:CreateButton(
13    "MakeWalls", -- Button Text
14    "MakeWalls Plugin: Click a part to create 3-stud-tall walls, of the same color, along it's edges.", --Text that appears when you hover over the button with the mouse
15    "9869681" -- Button Icon ID
View all 71 lines...

1 answer

Log in to vote
0
Answered by 10 years ago

Ah, I see what the issue is here.

1local y = targ.Position.Y+targ.Size/2

You're either setting y to a number or a Vector3. As you can see, at first, you're setting Y to a number because you put targ.Position.Y, and the Y position is a number. THEN, you're trying to get the ENTIRE size of the targ, which returns a Vector3 value, and dividing it by two.

A solution? Well, there's two ways. You can either set Y to a number (recommended), or set Y to a Vector3.

Y to a number (recommended): NOTE: I am really unsure of what you are trying to do right here. From what you're doing with the x variable, it looks like you want to do this.

1local y = targ.Position.Y + targ.Size.Y / 2

I am doing this because the X variable is set to local x = targ.Position.X - targ.Size.X / 2.

Hope this helps!

Ad

Answer this question