So basically, I’ve got a character customization function that should return if the player can wear that piece of clothing (whether they’re on in the specific group, team or own an asset)
For some reason, this doesn’t work as expected. Some people end up unlocking EVERYTHING when the requirements in the module obviously shouldn’t allow it. I’ve attempted to debug this for weeks and just ended up giving up. I did try adding less things to the module (2 items) and it worked fine, it’s as if the function got overloaded and decided to return true (obviously this isn’t what is happening but its just really confusing) I think it’s the way the function is checking the groups but I’m not sure anymore
Module:
(Rough selection of it so you can understand how I’m writing the requirements, full: https://pastebin.com/3JD1DG4p)
return {
Accessories = {
['Standard Issue Webbing'] = {
teamRequirements = {'Armed Forces', 'Basic Training'},
gamepassRequirements = {},
groupRequirements = {3877279},
accessories = {Webbing.Backpack}
},
},
Uniforms = {
['Grenadier Guard Formals'] = {
teamRequirements = {'Grenadier Guards'},
gamepassRequirements = {},
groupRequirements = {4428388},
shirts = {GrenUniform.CGGFormals},
pants = {GrenUniform.CGGFormalUniversal},
},
['The Founder'] = {
teamRequirements = {'The Founder'},
gamepassRequirements = {},
groupRequirements = {{Group = 3876907, Rank = {'-20'} }},
shirts = {StaffUniform.FoundersShirt},
pants = {StaffUniform.FoundersPants},
},
},
Covers = {
['Parachute Battalion Beret'] = {
teamRequirements = {'Parachute Battalion'},
gamepassRequirements = {},
groupRequirements = {4259147},
covers = {HatFolder['Parachute Battalion Beret']},
},
['Sovereigns Hat'] = {
teamRequirements = {'Community Manager'},
gamepassRequirements = {},
groupRequirements = {{Group = 3876907, Rank = {'-20'} }},
covers = {UniformFolder['Founders Hat']},
},
}
}
Check Function
module.PlayerHasAccessToUniform = function(Player, args)
local requirements = args.requirements
local requestedToCheck = args.requestingToCheck
-- Right so here, requestedToCheck is just a string such as `gamepassRequirement`
if requestedToCheck then
for _, value in next, requirements do
if requestedToCheck == 'gamepassRequirements' then
if marketPlaceService:UserOwnsGamePassAsync(Player.UserId, value) then
return true
end
elseif requestedToCheck == 'teamRequirements' then
if value == 'All' then
return true
elseif Player.Team.Name == value then
return true
else
return false
end
elseif requestedToCheck == 'groupRequirements' then
local function checkIfPlayerInGroup(group, rank, checkMoreThanOrEqual)
rank = tonumber(rank)
if Player:IsInGroup(group) then
--
if rank then
if checkMoreThanOrEqual then
if Player:GetRankInGroup(group) >= rank then
return true
end
else
if Player:GetRankInGroup(group) == rank then
return true
end
end
else
return true
end
else
return false
end
end
if type(value) == 'table' then
--print('Table value')
local group = value.Group
local rank = value.Rank or value.Ranks
if not rank then
return false
end
for _, id in next, rank do
local length = string.len(id)
if string.sub(id, string.len(1), string.len(1)) == '-' then
-- our value wants us to do rank >=
local newId = string.sub(id, 2, string.len(id))
--print('Checking2: '..group .. id)
local isIn = checkIfPlayerInGroup(group, id, true)
if isIn then
return true
end
else
--print('Checking2: '..group .. id)
local isIn = checkIfPlayerInGroup(group, id, nil)
if isIn then
return true
end
end
end
else
--print('Checking3: '..value )
return checkIfPlayerInGroup(value, nil, nil)
end
end
end
end
end
I think my main issue is coming from the groupRequirements check, my apologies if the code is a bit much I just can’t describe it any easier. I’ll happily answer any questions about the code if needed.
Thanks