Storing and group values in a table

  1. What do you want to achieve?

I want to have the position and name of a badge stored in a table with an infinite amount of other groups of name and position.

  1. What is the issue?

I have no clue how to group values in the table

  1. What solutions have you tried so far?

Just made a table lol

Here is all the code in the script

 local frame = script.Parent.Parent.userInterface.badgeFrame
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local inFrame = false
local shadow = Instance.new("TextLabel")
local shadow = Instance.new("TextLabel", script.Parent.Parent.userInterface.badgeFrame)
shadow.Size = UDim2.new(0,50,0,50)
shadow.Text = ""
shadow.BackgroundColor3 = Color3.new(0, 0.666667, 1)
shadow.AnchorPoint = Vector2.new(.5,.5)
shadow.Visible = false

local badges = {}

frame.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		local absPos = frame.AbsolutePosition
		local badge = Instance.new("TextLabel", script.Parent.Parent.userInterface.badgeFrame)
		badge.Size = UDim2.new(0,50,0,50)
		badge.Text = ""
		badge.BackgroundColor3 = Color3.new(0, 0.666667, 1)
		badge.AnchorPoint = Vector2.new(.5,.5)
		badge.Position = UDim2.new(0,mouse.X-absPos.X,0,mouse.Y-absPos.Y)
		print(badge.Position)
		
	end
end)

frame.MouseEnter:Connect(function()
	inFrame = true
	shadow.Visible=true
	while wait() do
		local absPos = frame.AbsolutePosition
		shadow.Position = UDim2.new(0,mouse.X-absPos.X,0,mouse.Y-absPos.Y)
		if inFrame == false then 
			break
		end
	end
end)

frame.MouseLeave:Connect(function()
	inFrame = false
	shadow.Visible=false
end)



1 Like

let me add some more clification.

16:05:31.476 â–Ľ {
[1] = {0, 117}, {0, 178},
[2] = “Blue Badge”
} - Client - placeBadges:27

local frame = script.Parent.Parent.userInterface.badgeFrame
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local inFrame = false
local shadow = Instance.new("TextLabel")
local shadow = Instance.new("TextLabel", script.Parent.Parent.userInterface.badgeFrame)
shadow.Size = UDim2.new(0,50,0,50)
shadow.Text = ""
shadow.BackgroundColor3 = Color3.new(0, 0.666667, 1)
shadow.AnchorPoint = Vector2.new(.5,.5)
shadow.Visible = false

local badges = {}
badges[1] = "Blue Badge"
frame.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		local absPos = frame.AbsolutePosition
		local badge = Instance.new("TextLabel", script.Parent.Parent.userInterface.badgeFrame)
		badge.Size = UDim2.new(0,50,0,50)
		badge.Text = ""
		badge.BackgroundColor3 = Color3.new(0, 0.666667, 1)
		badge.AnchorPoint = Vector2.new(.5,.5)
		badge.Position = UDim2.new(0,mouse.X-absPos.X,0,mouse.Y-absPos.Y)
		print(badge.Position)
		table.insert(badges,1,badge.Position)
		print(badges)
		
	end
end)

frame.MouseEnter:Connect(function()
	inFrame = true
	shadow.Visible=true
	while wait() do
		local absPos = frame.AbsolutePosition
		shadow.Position = UDim2.new(0,mouse.X-absPos.X,0,mouse.Y-absPos.Y)
		if inFrame == false then 
			break
		end
	end
end)

frame.MouseLeave:Connect(function()
	inFrame = false
	shadow.Visible=false
end)


I want the position of the badge to be with the “blue badge” in array index 1