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

I can't figure out how to do this one, can I get help? I tried a counter and a few other things

Asked by 7 years ago
Edited 7 years ago

Help please

script.Parent.ClickDetector.MouseClick:connect(function(Player)
    Player.PlayerGui.InventoryGui.Frame.Inventory.Inventory.Item1.ItemNumber.Value = script.Parent.ItemId.Value
    Player.PlayerGui.InventoryGui.Frame.Inventory.Inventory.Item1.Image = script.Parent.PicId.Value
end)

instead of always doing Item1 I need a way for it to detect which one is next out of 25... So like if the first 3 are taken i need it to automatically detect that and then fill in number 4. How can I do that?

here is the script now but it wont work... Please go to this link and look at the forum.

https://forum.roblox.com/Forum/ShowPost.aspx?PostID=210394171

script.Parent.ClickDetector.MouseClick:connect(function(Player)
    local Inventory = Player.PlayerGui.InventoryGui.Frame.Inventory.Inventory

local counter = 1

for i,v in next,Inventory:GetChildren() do 
   if i > counter then
       counter = i
       if v.BeingUsed.Value == false then 
        v.ItemNumber.Value = script.Parent.ItemId.Value
    v.Image = script.Parent.PicId.Value
    break
       end
   end
end
end)

1 answer

Log in to vote
0
Answered by 7 years ago

Probably not the best to do this but:

Base = "Item"
Start = 1
End = 25

script.Parent.ClickDetector.MouseClick:connect(function(Player)
    if Current == End or Current == nil then
        Current = Start
    end
    String = Base..tostring(Current)
    Player.PlayerGui.InventoryGui.Frame.Inventory.Inventory[String].ItemNumber.Value = script.Parent.ItemId.Value
    Player.PlayerGui.InventoryGui.Frame.Inventory.Inventory[String].Image = script.Parent.PicId.Value
    Current = Current +1
end)

0
thx Stephenthefox 94 — 7y
Ad

Answer this question