--Edit-- Found a small error in a different part of the script that was causing this and got it fixed.
I have a module script (MainModule) in my game and it manages all the players' data/stats. I have a function to return stat data to other script that need it, however, I'm always getting 'true' instead of all the data that was in the table. I even have it print out all the data in the table before it returns it so I can confirm that it doesn't just say 'true' inside the table.
-- This is a snippet my ModuleScript function MainModule:ReturnData(player) print("Started return data") if player then print("Player exists") local ActualPlayer = game:GetService("Players"):FindFirstChild(tostring(player)) if sessionData[ActualPlayer] then print("Session data exists") return dataStoreRetry(function() print("Sent Data") for i,v in pairs(sessionData[ActualPlayer]) do print(i,v) -- It prints out the data in the table perfectly end return sessionData[ActualPlayer] end) end end end
So if I were to request it from another script like this:
local MainModule = require(script.Parent.MainModule) -- In ServerScriptService function Test() local PlayerData = MainModule:ReturnData("Crazycat4360") print(PlayerData) -- This returns true instead of the data in the table for i,v in pairs(PlayerData) do print(i,v) -- This errors because PlayerData is returning as a boolean (true) instead of the data that was in the table. end end
It returns true instead of the data in the table! Is there something I'm not understanding? Thanks.
i just had a glance at the code, but try this:
for i, v in pairs (PlayerData) do print(v) end