Player folder not changing on client side

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I’m making an inventory system for my game, similar to Minecraft inventory.

  2. What is the issue? Include screenshots / videos if possible!
    To make it, I decided to create a folder with all inventory slot information in player’s instance, but when I tried to update the GUI, inventory was empty on client-side only.
    image
    image
    image
    image

What I saw on 1st slot properties:
Client side


Server side

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried to get folder’s instances from invoking a remote function to server that returns them, but it was the same result.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

Server side code (folder and slot instances):

game.Players.PlayerAdded:Connect(function (plr)
	local Inventory = Instance.new("Folder")
	Inventory.Name = "Inventory"
	Inventory.Parent = plr
	local InvGui = plr.PlayerGui:WaitForChild("Inventory")
	for i=1,40 do
		local item = Instance.new("ObjectValue")
		item.Parent = Inventory
		item.Name = i
		item.Changed:Connect(function ()
			game.ReplicatedStorage.UpdateInventory:FireClient(plr)
		end)
		local amount = Instance.new("IntValue")
		amount.Name = "Amount"
		amount.Value = 0
		amount.Parent = item
		amount.Changed:Connect(function ()
			game.ReplicatedStorage.UpdateInventory:FireClient(plr)
		end)
	end
	local EqVal = Instance.new("IntValue")
	EqVal.Value = 1
	EqVal.Name = "Equipped"
	EqVal.Parent = Inventory
	EqVal.Changed:Connect(function ()
		local char = plr.Character
		if char:FindFirstChildOfClass("Tool") then
			char:FindFirstChildOfClass("Tool"):Destroy()
		end
		if Inventory[EqVal.Value].Value then
			local tool = Inventory[EqVal.Value].Value:Clone()
			tool.Parent = char
		end
	end)
	Inventory[1].Value = game.ServerStorage.Items["Iron Sword"]
end)

Client side code (GUI updating):

local ui = script.Parent
task.wait(0.1) --to make sure that all slots are generated in other script
local slots = {}

for _,v in ui:GetDescendants() do
	if v.Name == "Slot" then
		print("Added slot")
		table.insert(slots,v)
	end
end

local event = game.ReplicatedStorage.UpdateInventory
local plr = game.Players.LocalPlayer
event.OnClientEvent:Connect(function ()
	print("Updating Inventory...")
	local Inventory = plr:WaitForChild("Inventory")
	for i=1,40 do
		for _,v in slots do
			if v.SlotID.Value == i then
				--print("Updating Slot ",i)
				if Inventory[i].Value then
					local item = Inventory[i].Value:Clone()
					if #v.Image.Space.Item:GetChildren() > 0 then
						for _,a in v.Image.Space.Item:GetChildren() do
							a:Destroy()
						end
					end
					item.Parent = v.Image.Space.Item
					if Inventory[i].Amount.Value > 0 then
						v.Amount.Visible = true
						v.Amount.Text = Inventory[i].Amount.Value
					end
				else
					--print("No item")
					if #v.Image.Space.Item:GetChildren() > 0 then
						for _,a in v.Image.Space.Item:GetChildren() do
							a:Destroy()
						end
					end
					v.Amount.Visible = false
					v.Amount.Text = Inventory[i].Amount.Value
				end
			end
		end
	end
end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

maybe the player folder is only server sided?

there are no disadvantages as hackers can only control the client…

Ah, maybe I see why.
All of the items that exist in game are stored in ServerStorage, and since client cannot access it, it’s nil.

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