Hi. So like I am creating a Gun Spawner Gui. Since there is so much Guis, I dont think I should be writing them out too much. So I did this.
local Player = game:GetService("Players").LocalPlayer
local PGui = Player:WaitForChild("PlayerGui")
local tab = {
[1] = PGui.ScreenGui["Ksg"],
[2] = PGui.ScreenGui["HecateII"],
[3] = PGui.ScreenGui["Intervention"],
[4] = PGui.ScreenGui["AK104"],
[5] = PGui.ScreenGui["HK416"],
...
}
for i, v in pairs(tab) do
v.MouseButton1Down:Connect(function()
print(v.Name)
end)
end
They work perfectly fine. But see, I want to create a spawning right. I dont want to make a big if statement checking the v's name. What i mean is like this.
if v.Name == "Ksg" then
Ksg:Clone()
elseif v.Name == "HecateII" then
HecateII:Clone()
...
end
I dont want to do it this way because I have a lot of guns and I think there is a better way to solve this but Idk how to do it.
Thank you if you can help me. :D

1 comment
Doing like you did with
tab, you could also do the same for the weapons. :DTable['Gun_Name'] = Gun