Well, I want to make a game with classes in it, and there is a special class called “Lightinfantry”, but I only want to give it out to certain people. The default class is “Fusiliers”.
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Class = Instance.new("IntValue", leaderstats)
Class.Name = "Class"
local Fusilier = "Fusilier"
Class.Value = Fusilier
local Lightinfantry = "Lightinfantry"
end)
This is what I have, but how do I make it give LightInfantry to only certian people, and gives out weapons in the starter pack to only people with that role.
You would make a table with a list of Id’s of certain users.
You would then loop through the table and compare if the players ID matches one of the Id:s on the table.
If the Id does match you would them give them the other value
Example
--// Services
local Players = game:GetService("Players")
--// Components
-- Create a table with Id's
local SpecialUsers = {1,5378439822} -- Just add user Id's of the users you want to have the Lightinfantry Rank. Separate new Id:s with commas
--//Handler
Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Class = Instance.new("IntValue", leaderstats)
Class.Name = "Class"
local Fusilier = "Fusilier"
Class.Value = Fusilier
--Loop through the SpecialUsers Table
for i,v in pairs(SpecialUsers)do
if(player.UserId == v)then -- If the players Id matches any Id in the table
local LightinfantryClass = Instance.new("IntValue", leaderstats)
Lightinfantry.Value = "Lightinfantry"
-- Add this to them
end
end
end)
local Class = Instance.new("StringValue", leaderstats)
Class.Name = "Class"
if table.find(SpecialClassPlayers, plr.UserId) then
local Fusilier = "Fusilier"
Class.Value = Fusilier
else
print("plr UserId not found")
end
--// Components
-- Create a table with Id's
local SpecialUsers = {326555533, 406340380, 1779940452} -- Just add user Id's of the users you want to have the Lightinfantry Rank. Separate new Id:s with commas
--//Handler
Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Class = Instance.new("IntValue", leaderstats)
Class.Name = "Class"
local Fusilier = "Fusilier"
Class.Value = Fusilier
local Lightinfantry = "Lightinfantry"
if table.find(SpecialUsers, player.UserId) then
Class.Value = Lightinfantry
else
print("plr UserId not found")
end
end)
This is what I have down, I probably did this wrong, but it doesn’t work.
local Players = game:GetService("Players")
--// Components
-- Create a table with Id's
local SpecialUsers = {326555533, 406340380, 1779940452} -- Just add user Id's of the users you want to have the Lightinfantry Rank. Separate new Id:s with commas
--//Handler
Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder", player)
leaderstats.Name = "leaderstats"
local Class = Instance.new("StringValue", leaderstats)
Class.Name = "Class"
local Fusilier = "Fusilier"
local Lightinfantry = "Lightinfantry"
if table.find(SpecialUsers, player.UserId) then
Class.Value = Lightinfantry
else
print("plr UserId not found")
Class.Value = Fusilier
end
end)
I just had to change it to string value. thx bois/girls.