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

No clue.. Not a master with tables.. Anyone know how to fix this?

Asked by 10 years ago
01function OnHover(plr)
02    if script.Parent:FindFirstChild("SelectionBox") == nil then
03    f = Instance.new("SelectionBox")
04    f.Parent = script.Parent
05    f.Adornee = script.Parent
06    if script.Parent:FindFirstChild("Humanoid") == nil then
07    h = Instance.new("Humanoid")
08    h.Parent = script.Parent.Parent
09    h.MaxHealth = 0
10    h.Health = 0
11    script.Parent.Parent.Name = script.Parent.Parent.Name .. " [F]"
12mouse = plr:GetMouse()
13Slot1 = plr.PlayerGui.Inventory.Scrolling.Slot1
14Slot2 = plr.PlayerGui.Inventory.Scrolling.Slot2
15Slot3 = plr.PlayerGui.Inventory.Scrolling.Slot3
View all 76 lines...

Now you see, the problem is, the image goes into the Gui and it goes in to all of them.

Anyone know a fix or maybe a way to add a table and test every slot to make sure it isn't equal to Rock or Nothing.

0
You spelled SelectionBox wrong on line 2. SlickPwner 534 — 10y
0
So I did. Thanks for noting that out. Can't believe I didn't notice that. legoguy939 418 — 10y
0
legoguy939: As a question asker, you should *accept* posts, even if you can't upvote them (green check mark) BlueTaslem 18071 — 10y

1 answer

Log in to vote
3
Answered by
Ekkoh 635 Moderation Voter
10 years ago
1if Slot1.Item.Value == "Nothing" or "Rock" then

Has to be

1if Slot1.Item.Value == "Nothing" or Slot1.Item.Value == "Rock" then

When you have the first, the if statement is actually checking two conditions. The first being Slot1.Item.Value == "Nothing", and the second being "Rock". In the case that Slot1.Item.Value does not equal "Nothing", the if statement will result to the expression after the or. Since "Rock" is neither nil nor false, it treats it as true, causing the whole expression to become true, causing the code inside the following scope to execute. So just make sure you explicitly state what you're comparing the value to, like so in the second example.

0
I'd upvote this but I can't because I have -1 rep. :( I'll see if this works. legoguy939 418 — 10y
Ad

Answer this question