Skip to content

Commit

Permalink
fix error with leaderstats
Browse files Browse the repository at this point in the history
  • Loading branch information
James committed Sep 29, 2023
1 parent aa9ec0c commit 7c35575
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions src/lua/framework/Vendor/Libraries/EasyProfile/init.luau
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,18 @@ function ProfileObject:CreateProfileLeaderstats(player: Player, statsToAdd: {str
local LeaderstatsFolder = Instance.new("Folder")

for key, value in statsToAdd or Profile.Data do
local ValueType = type(value)
local keyVar, valueVar = key, value

if type(key) == "number" then
if not Profile.Data[value] then
error(`{value} is not a member of the profile data.`)
end

keyVar = value
valueVar = Profile.Data[value]
end

local ValueType = type(valueVar)

if not table.find(ValidLeaderboardTypes, ValueType) then
continue
Expand All @@ -260,8 +271,8 @@ function ProfileObject:CreateProfileLeaderstats(player: Player, statsToAdd: {str
local StatClass = `{ValueType:gsub("^%l", string.upper)}Value`
local NewStat = Instance.new(StatClass)

NewStat.Name = key
NewStat.Value = value
NewStat.Name = keyVar
NewStat.Value = valueVar
NewStat.Parent = LeaderstatsFolder
end

Expand All @@ -271,6 +282,17 @@ function ProfileObject:CreateProfileLeaderstats(player: Player, statsToAdd: {str
return LeaderstatsFolder
else
for attribute, value in statsToAdd or Profile.Data do
local attributeVar, valueVar = attribute, value

if type(attribute) == "number" then
if not Profile.Data[value] then
error(`{value} is not a member of the profile data.`)
end

attributeVar = value
valueVar = Profile.Data[value]
end

if not table.find(ValidAttributeTypes, typeof(value)) then
continue
end
Expand Down

0 comments on commit 7c35575

Please sign in to comment.