I am making a plugin that creates walls along the edges of the selected part, but it keeps coming out with this error:
1 | 08 : 10 : 43.551 - Plugin_ 191344304. MakeWalls.Script: 50 : bad argument # 1 to '?' (Vector 3 expected, got number) |
2 | 08 : 10 : 43.552 - Script 'Plugin_191344304.MakeWalls.Script' , Line 50 |
3 | 08 : 10 : 43.552 - Stack End |
4 | 08 : 10 : 43.553 - Disconnected event because of exception |
The code is here:
01 | local pluginVersion = 0.35 |
02 | local hasLoaded = plugin:GetSetting( "pluginHasLoaded" ) |
03 | print ( "Loading ExplosionCreate Plugin v" .. pluginVersion) --Just a loading message |
04 | if not hasLoaded then |
05 | plugin:SetSetting( "pluginHasLoaded" , true ) |
06 | end |
07 |
08 | -- Setup Toolbar |
09 | local toolbar = plugin:CreateToolbar( "dudemanloserr Productions" ) --Toolbar Name |
10 | local isActive = false |
11 | -- Setup button |
12 | local 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 |
Ah, I see what the issue is here.
1 | local 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.
1 | local 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!