|
But it did work in commandbar.
Why?
local Selected = game.Selection:Get()
if not Selected[1]:IsA("GuiObject") then
rint("Please make sure the selected object can be classified as a GuiObject")
elseif #Selected ~= 1 then
print("Please only select 1 gui item")
elseif #Selected == 1 and Selected[1]:IsA("GuiObject") then
--CODING
end
I need this to work... My previous layout was like this;
local Selected = game.Selection:Get()
if #Selected ~= 1 then
print("Please only select 1 gui item")
elseif not Selected[1]:IsA("GuiObject") then
rint("Please make sure the selected object can be classified as a GuiObject")
else
--code
end
and it would ALWAYS print "Please only select 1 gui item"
If you could fix EITHER of these, please do so ;D |
|
|
I forgot to mention the error for
local Selected = game.Selection:Get()
if not Selected[1]:IsA("GuiObject") then
rint("Please make sure the selected object can be classified as a GuiObject")
elseif #Selected ~= 1 then
print("Please only select 1 gui item")
elseif #Selected == 1 and Selected[1]:IsA("GuiObject") then
--CODING
end
was
attempt to index field '?' (a nil value) |
|
|
The line number is 104 which would be this line;
if not Selected[1]:IsA("GuiObject") then |
|
KingJackoJoin Date: 2008-06-20 Post Count: 3944 |
rint("Please make sure the selected object can be classified as a GuiObject")
rint
RINT
|
|
|
I have no idea why it says rint on the post I made, but in studio it's print, so please ignore that lol. |
|
|
Here's my newest layout. Works just fine;
local Selected = game.Selection:Get()
if #Selected ~= 1 then
print("Please only select 1 gui item")
elseif not Selected[1]:IsA("GuiObject") then
print("Please make sure the selected object can be classified as a GuiObject")
elseif #Selected == 1 and Selected[1]:IsA("GuiObject") then
EXCEPT FOR THE FACT THAT IT ALWAYS PRINTS "Please only select 1 gui item" |
|
|
|
fret13103Join Date: 2010-03-15 Post Count: 881 |
You have more than one item selected. |
|
|
No I don't...
It prints weather I do or I don't. Infact, it'll say #Selected ~= 1 and that #Selected == 1
It's not making any sense.
It will go through if #Selected ~= 1 then and after it'll go thru the code where it says elseif #Selected == 1 and Selected[1]:IsA("GuiObject") then
?!?!?! |
|
|
|
local SeIected = game.SeIection:Get()
if #Selected ~= 1 then
while true do
print("Please only select 1 gui item")
end
elseif not Selected[1]:IsA("GuiObject") then
print("Please make sure the selected object can be cIassified as a GuiObject")
elseif #Selected == 1 and Selected[1]:IsA("GuiObject") then |
|
|
|
|
|
|
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
Your error is that if nothing is selected, you can't call IsA on a nil value.
if #selected > 0 then
--etc
end |
|
|
If nothing is selected it shouldn't. Call IsA on nil, it should print Please only select 1 gui item, because #Selected ~= 1 should return true.
For some reason #Selected ~= 1 returns true, (it still returns true even when it's false) however it continues to run through the elseif statements? |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
That still allows it to be 0. |
|
|
Yes
if #Selected ~= 1 then --If it's less or more than 1 (includes 0)
print("Please only select 1 gui item") --Print
elseif not Selected[1]:IsA("GuiObject") then --This should only run if it IS 1
rint("Please make sure the selected object can be classified as a GuiObject") --Print, this'll print if they've got 1 object selected, and it is not a GuiObject
--Rest of my code cause this is unnesecary. |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
I mean the else will run if it is 0 too |
|
cntkillmeJoin Date: 2008-04-07 Post Count: 49450 |
wait nevermind.
Which code are you using? Top or bottom |
|
|
You're not getting this...
If the initial if statement returns true none of the others should execute. |
|