So, I’m working on a system where a script hands out items based on a players rank in a group, however it wont do anything.
here is my script:
local module = require(script.Parent)
local items = script.AllItems
local groupId = 7732854
game.Players.PlayerAdded:Connect(function(plr)
if plr:GetRankInGroup(groupId) >= module.Personell then
local clone = items["Level 1 Clearance"]:Clone()
clone.Parent = plr.Backpack
end
if plr:GetRankInGroup(groupId) >= module.Specialist then
local clone = items["Level 2 Clearance"]:Clone()
clone.Parent = plr.Backpack
end
if plr:GetRankInGroup(groupId) >= module.Captain then
local clone = items["Level 3 Clearance"]:Clone()
clone.Parent = plr.Backpack
end
if plr:GetRankInGroup(groupId) >= module["Junior Officer"] then
local clone = items["Level 4 Clearance"]:Clone()
clone.Parent = plr.Backpack
end
if plr:GetRankInGroup(groupId) >= module.Colonel then
local clone = items["Level 5 Clearance"]:Clone()
clone.Parent = plr.Backpack
end
end)
Please help!
Try adding prints to see what runs:
local module = require(script.Parent)
local items = script.AllItems
local groupId = 7732854
game.Players.PlayerAdded:Connect(function(plr)
if plr:GetRankInGroup(groupId) >= module.Personell then
print("personnel")
local clone = items["Level 1 Clearance"]:Clone()
clone.Parent = plr.Backpack
end
if plr:GetRankInGroup(groupId) >= module.Specialist then
print("specialist")
local clone = items["Level 2 Clearance"]:Clone()
clone.Parent = plr.Backpack
end
if plr:GetRankInGroup(groupId) >= module.Captain then
print("captain")
local clone = items["Level 3 Clearance"]:Clone()
clone.Parent = plr.Backpack
end
if plr:GetRankInGroup(groupId) >= module["Junior Officer"] then
print("junior officer")
local clone = items["Level 4 Clearance"]:Clone()
clone.Parent = plr.Backpack
end
if plr:GetRankInGroup(groupId) >= module.Colonel then
print("colonel")
local clone = items["Level 5 Clearance"]:Clone()
clone.Parent = plr.Backpack
end
end)
Its not printing anything. Let me try changing module.Colonel to the actual rank id
Update: that did not work.
Can I see the module? It might be a string instead of a number.
Also, try printing the rank like this.
local module = require(script.Parent)
local items = script.AllItems
local groupId = 7732854
game.Players.PlayerAdded:Connect(function(plr)
print(plr:GetRankInGroup(groupId))
if plr:GetRankInGroup(groupId) >= module.Personell then
print("personnel")
local clone = items["Level 1 Clearance"]:Clone()
clone.Parent = plr.Backpack
end
if plr:GetRankInGroup(groupId) >= module.Specialist then
print("specialist")
local clone = items["Level 2 Clearance"]:Clone()
clone.Parent = plr.Backpack
end
if plr:GetRankInGroup(groupId) >= module.Captain then
print("captain")
local clone = items["Level 3 Clearance"]:Clone()
clone.Parent = plr.Backpack
end
if plr:GetRankInGroup(groupId) >= module["Junior Officer"] then
print("junior officer")
local clone = items["Level 4 Clearance"]:Clone()
clone.Parent = plr.Backpack
end
if plr:GetRankInGroup(groupId) >= module.Colonel then
print("colonel")
local clone = items["Level 5 Clearance"]:Clone()
clone.Parent = plr.Backpack
end
end)
local ranks = {
["Personell"] = 1;
["Operative"] = 239;
["Senior Operative"] = 240;
["Specialist"] = 241;
["Senior Specialist"] = 242;
["Corporal"] = 243;
["Sergeant"] = 244;
["Captain"] = 245;
["Junior Officer"] = 246;
["Officer"] = 247;
["Major"] = 248;
["Lt Col"] = 249;
["Colonel"] = 250;
}
return ranks
Also, its still not printing anything
Instead of your old script, try this:
if plr:GetRankInGroup(groupId) >= module["Junior Officer"] then
items["Level 4 Clearance"]:Clone().Parent = plr.Backpack
end
Let me know if this helps
You should check into this error…
Are you sure? I tried the script in studio and the event fired just fine.
I moved the script, now im getting the prints, but it still wont copy the items to my backpack.
Oh also, you do not have a group ID connected.
Your solution worked! thank you!!!