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")
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””
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.
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
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.
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).
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.