I’m looking to create a system where BoolValues are loaded into a folder inside the player, and a UI is changed depending on the result, so for example, if ___ value is set to true, ___ frame becomes visible, etc.
The issue I’m facing however is the local script does not recognize the folder at all. I tried fixes such as referencing the folder in the server script, but each time returns with a similar error:
The datastore is not the problem, the values save, the RemoteEvent fires, but I can’t get it to reference the folder stored inside the player.
local function onPlayerJoin(player)
local Inventory = Instance.new("Folder")
Inventory.Name = "Inventory"
Inventory.Parent = player
local money = Instance.new("BoolValue")
money.Name = "ExampleNametag"
money.Parent = Inventory
local exp = Instance.new("BoolValue")
exp.Name = "ExampleParticle"
exp.Parent = Inventory
local playerUserId = "Player_" .. player.UserId
local data = playerData:GetAsync(playerUserId)
if data then
money.Value = data['ExampleNametag']
exp.Value = data['ExampleParticle']
money.Value = false
exp.Value = false
if player.Inventory.ExampleParticle.Value == true then
script.Parent.Text = "You own the item!"
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local LocalPlayer = Players.LocalPlayer
local RemoteEvent = ReplicatedStorage.valuesDoneLoading
local TextLabel = script.Parent
if LocalPlayer.Inventory.ExampleParticle.Value then
TextLabel.Text = "You own the item!"
The FireClient function works by firing the client of the player which is specified in the first parameter and then the wanted parameters go after that.
In this line you do not need to add the player parameter to the OnClientEvent line because the you are not passing any parameters and the OnClientEvent automatically detects the player. Instead, you can add this line above the OnClientEvent line:
local player = game.Players.LocalPlayer
Also remove the “player” parameter from the OnClientEvent if you already haven’t.
Although looking at scripts can sometimes show you what mistakes you’ve made, I thought I’d make an explanation instead of just sending scripts. This way, it will be more easy for you to understand.