(sorry for the title, feel free to put this in r/titlegore lol)
I made a loadout system for a shooter game I made to play with my friends, there are 2 teams, the army and the insurgents, but I have a problem, I want players in the army to be able to only see and be able to pick military guns from the loadout screen, and insurgents to be able to only see and pick guns such as AKs and MAC-10, currently everyone can see the same weapons and for example army can take guns like AK, which is something I don’t want to happen.
Server:
local levent = game.ReplicatedStorage:WaitForChild("LoadoutEvent")
local pfolder = game.ReplicatedStorage:WaitForChild("Primary")
local sfolder = game.ReplicatedStorage:WaitForChild("Secondary")
levent.OnServerEvent:connect(function(client, event, choice)
local player = client
if event == "Primary" and client then
local ptool = pfolder:FindFirstChild(choice)
local newptool = ptool:clone()
newptool.Parent = player.Backpack
elseif event == "Secondary" and client then
local stool = sfolder:FindFirstChild(choice)
local newstool = stool:clone()
newstool.Parent = player.Backpack
end
end)
Client:
p = script:WaitForChild("Primary")
s = script:WaitForChild("Secondary")
local pstore = game.ReplicatedStorage:WaitForChild("Primary")
local primary = pstore:GetChildren()
local levent = game.ReplicatedStorage:WaitForChild("LoadoutEvent")
local pos = UDim2.new(0,0,0,0)
for i=1,#primary do
local guibutton = script.TextButton:Clone()
guibutton.Parent = script.Parent.P
guibutton.Position = pos
guibutton.Text = primary[i].Name
pos = pos + UDim2.new(0,0,0.07,0)
function clicked()
p.Value = guibutton.Text
end
guibutton.MouseButton1Down:connect(clicked)
end
local sstore = game.ReplicatedStorage:WaitForChild("Secondary")
local secondary = sstore:GetChildren()
local pos = UDim2.new(0,0,0,0)
for i=1,#secondary do
local guibutton = script.TextButton:Clone()
guibutton.Parent = script.Parent.S
guibutton.Position = pos
guibutton.Text = secondary[i].Name
pos = pos + UDim2.new(0,0,0.07,0)
function clicked()
s.Value = guibutton.Text
end
guibutton.MouseButton1Down:connect(clicked)
end
function enter()
levent:FireServer("Primary",p.Value)
levent:FireServer("Secondary",s.Value)
script.Parent:remove()
end
script.Parent.Enter.MouseButton1Down:connect(enter)
I’m pretty sure I should add folders to separate army and insurgent primaries/secondaries but idk how I would show the guns depending on the team.