How to make function to get player data using profile service?

script:

RemoteFunctions.GetData.OnServerInvoke = function(player: Player)
	local Profiles = PlayerDataHandler.Profiles[player]
	
	print(Profiles)
	
	local profile = Profiles.Data
	if not profile then return end
	
	print(profile)

	return profile
end

local script:

local data = RemoteFunctions.GetData:InvokeServer(Player)
print(data)

Make sure “Player” on the client is equal to the local player.

This is my server script:

local PlayerDataHandler = require(game.ServerScriptService.PlayerDataHandler)

PlayerDataHandler.Init()

game.ReplicatedStorage.RemoteFunction.OnServerInvoke = function(player: Player)
	local Profiles = PlayerDataHandler.Profiles[player]

	print(Profiles)

	local profile = Profiles.Data
	if not profile then return end

	print(profile)

	return profile
end

This is my local script:

local data = game.ReplicatedStorage.RemoteFunction:InvokeServer(game.Players.LocalPlayer)
print(data)

Everything works fine for me.


image
player is determined

Oh yes, my bad on that, I still can’t find the issue however.

try waiting a second before invoking server. I don’t think this is the issue, but I want to see if you are invoking the server before the data has been set.

1 Like

yeah damn thanks it worked

▼ {
[“Coins”] = 494,
[“Exp”] = 0,
[“Level”] = 1,
[“Location”] = “Spawn”,
[“Need”] = 100,
[“Rasa”] = “Human”,
[“Rebirths”] = 0
} - Client - Manager:38

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.