Hey! I’m making a title system but can’t figure out how to fix this bug. Every time I try and return a Boolean like true or false it don’t update until I rejoin the game.
local function GetData(ItemName, TitlesData)
for _, TitleName in pairs(TitlesData) do
if tostring(ItemName) == tostring(TitleName) then
return true -- It is true but still returns false **until** I rejoin the game.
end
end
return false
end
local CheckData = GetData(ItemName, TitlesData)
if CheckData == true then
print("Owns")
else
print("Dont Own"
end
The print, you forgot to close the bracket. For the returns, I am not really sure. Is it the full code? If you stick with this issue, I would place the player to your game again so the data change with a prompt if we can’t solve this.
It seems to be an issue with either an outdated ItemName or outdated TitlesData that only update properly on a rejoin. The code works fine, but it’s probably something wrong with how you’re getting these 2 values to give to the function.
May we see the code you have that contains the call to GetData?
local function GetPlayerData()
return EventModule.ClientCall("FetchClientData", "ScrollingFrame")
end
local function MakeButtons(i, v)
local Data = GetPlayerData()
local ItemName = v.Name
local TitlesData = Data["Titles"]
local CheckData = GetData(ItemName, TitlesData)
end
function TitleHandler:Int()
for i,v in pairs(Titles) do -- Titles is a module where I add titles
MakeButtons(i,v)
end
end
That’s just the CheckData value, if I own it and rejoin it will print “Owns” but it will not update until I rejoin, and that’s what I’m trying to figure out
There seems to be no errors. Maybe storing it using DataStores, so you store the rank immediatly once purchased, then you would change the title text to “RANK NAME HERE.” With example with DataStores when Immediatly purchased: