Roblox Profile service check for value in table

Hello, im trying to check in my Profile Service Table if a certain value named “Fireball” exists, if so it prints it.

Here are the basics so far

local PlayerDataHandler = require(game.ServerScriptService:WaitForChild("PlayerDataHandler"))
local player = game.Players.LocalPlayer


PlayerDataHandler:Get(player, "Spells")
3 Likes
local spells = PlayerDataHandler:Get(player, "Spells")
--if it's an array
if table.find(spells, "Fireball") then
	print("The fireball exists!")
end
--if it's a dictionary and Fireball is the key
if spells["Fireball"] ~= nil then
	print(spells["Fireball"])
end

Thanks for the code! I put it in my script but this popped up in the console “Infinite yield possible on ‘ServerScriptService:WaitForChild(“PlayerDataHandler”)’”

And it now says (having changed local PlayerDataHandler = require(game.ServerScriptService:WaitForChild(“PlayerDataHandler”)) to local PlayerDataHandler = require(game.ServerScriptService.PlayerDataHandler) ) “PlayerDataHandler is not a valid member of ServerScriptService “ServerScriptService””

1 Like

And it nows says “Invalid Argument”

1 Like

Basically, the issue is that PlayerDataHandler doesn’t exist inside ServerScriptService. This is your own code not mine so I can’t help with that unless I have more information about what PlayerDataHandler even is and where it is located.

1 Like

Well, PlayerDataHandler is a Module script thats used to store values and datastore them too made with the Profile Service module. And it is indeed located in ServerScriptService

1 Like

The fact WaitForChild yields means it was unable to find it within 5 seconds of waiting(the default wait time). So for the first 5 seconds of the game start the module isn’t there or at least not under ServerScriptService directly.

1 Like

image

Perhaps you messed up the naming? Look if you have added any spaces or invisible characters after the module name, if so then remove them.

1 Like

Hmm it seems like there is no spaces or invisibles characters. Here is the line i used to find it btw


and the error
image

1 Like

Invalid argument in require means the argument/instance is nil. This means that the game can’t find the module instantly(I mention instantly here because you used FindFirstChild), try changing to WaitForChild and also ensure the string inside the require(PlayerDataHandler) is equal to the module name(no invisible spaces or anything).

1 Like

Im gonna try to change it to WaitForChild. Perhaps it is because there is another module script in server script service

1 Like

The other module has a different name so that has nothing to do with it.

I just changed it to WaitForChild and now the error goes back to

Have an idea why this happens?

I put the local script in starter gui would it be linked to the problem?

Ah its maybe because when i launch the game everything in server script service dissapears

That’s the issue, it should be a script not a local script, else it can’t see what the server sees(for example scripts under ServerScriptService) and thus thinks the module doesn’t exist.

1 Like

Now it says