Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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)

1 comment

0

thx

This discussion is preserved as it was. New answers, comments, and votes are closed.