This is my script, if I join first, it gives me the tool but if someone joins as Shiekh Al Khara after me, it doesn’t give Shiekh Al Khara the tool? Any help?
--// Variables and Services
local GroupId = 6401031
local CharHide = 0
local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")
Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = 'leaderstats'
leaderstats.Parent = player
local Rank = Instance.new("StringValue")
Rank.Name = 'Rank'
Rank.Value = 'Guest'
Rank.Parent = leaderstats
if player:IsInGroup(GroupId) then
local role = player:GetRoleInGroup(GroupId)
if string.len(role) <= CharHide then
warn('[GroupLeaderboard] Attempted to hide more characters than role has; using default name')
Rank.Value = role
else
local role = string.sub(role, CharHide+1)
Rank.Value = role
end
end
local function giveAccessCard()
if player.leaderstats.Rank.Value == "Royal Family" or "Sheikh Al Khara" then
local accessCard = ServerStorage:WaitForChild("Tools")["Royal Access Card"]:Clone()
accessCard.Parent = player:WaitForChild("Backpack")
end
end
player.CharacterAdded:Connect(function(Character)
Character:WaitForChild("Humanoid").DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
end)
giveAccessCard()
end)