Profile service BUGGING (Help>)

function PlayerDataHandler:Update(player, key, callback)
	local profile = getProfile(player)

	local oldData = self:Get(player, key)
	local newData = callback(oldData)
	
	if player.leaderstats:FindFirstChild(key) then
		print(key)
		player.leaderstats:FindFirstChild(key).Value = key
	end

	self:Set(player, key, newData)
end

return PlayerDataHandler

thats my update function

	local PlayerDataHandler = require(game.ServerScriptService:WaitForChild("Modules").PlayerDataHandler)
	
	PlayerDataHandler:Update(player, "ChosenElf", function(ChosenElf2)
		return ChosenElf2 == chosenElfName
	end)

And here is where im calling it from

but it keeps sending this error

attempt to concatenate string with boolean
or
Data does not exist for key: ChosenElf
or
assertion failed!
just spitting out random errors

“chosenElfName”

is

this
RemoteEvent.OnServerEvent:Connect(function(player, chosenElfName)

any idea why?

Im guessing you also watched dot products tutorial on setting up profile service. I think in your case it would be more appropriate to use :Set instead of update

can you paste the lines of code that you are getting these errors from. My guess is that its from :set since it looks pretty similar to my :set

function PlayerDataHandler:Set(player, key, value)
	local profile = PlayerDataHandler:getProfile(player)
	assert(profile.Data[key], string.format("Data does not exist for key: %s", key))
	assert(type(profile.Data[key]) == type(value))
	profile.Data[key] = value
end

You should double check that chosenElfName is a string using print(typeof(chosenElfName)

2 Likes

yea that works!

i tried it before with no luck, but trying it now it does work

so thanks!

1 Like

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