Folder with inventory slots not showing up

so, there is a tutorial that makes a inventory system(not a mmorpg one i think) but in some part of the tutorial, the person makes 4 string values for inventory slots but when i tried it didnt happen, i tried putting other numbers and it isnt the number of slots(at least i think), the tutorial uses 3 scripts, 1 normal and 2 module scripts

normal one

local plr = game:GetService("Players")

local promptService, promptManager = game:GetService("ProximityPromptService"), require(script.prompt)

local init = require(script.init)


function playerAdded(p)
	init.create(p)
end

plr.PlayerAdded:connect()

for _, p in next, plr:GetPlayers() do
	spawn( function() playerAdded(p) end)
end

(the prompt thing will be used later i think)

the module one that creates a inventory folder

local slots = 20
function module.create(p)
	local main = Instance.new("Folder")
	main.parent = p
	main.Name = "main"
	
	for i = 1, slots do
		local slot = Instance.new("StringValue")
		slot.parent = main
		slot.Name = tostring("slot " .. i)
	end
end

what could be wrong in it?(just tell me the error and i’ll try to fix it if i can)

wait, shouldnt it have something like “waitforchild” for players?

Try this and let me know how it goes.

Your normal script

local Players = game:GetService("Players")
local promptService = game:GetService("ProximityPromptService")
local promptManagerrequire(script.prompt)

local init = require(script.init)


Players.PlayerAdded:connect(function(Player)
	init.create(Player)
end)

Your module script

local Slots = 20

function module.create(Player)
	local Folder = Instance.new("Folder")
	Folder.Parent = Player
	Folder.Name = "main"

	for i = 1, Slots, 1 do
		local slot = Instance.new("StringValue")
		slot.Parent = Folder
		slot.Name = tostring("slot " .. i)
	end
end

It depends. If it runs right away when the server starts or when the player joins a game then you would need to do that so it can wait for the inventory slots.

Sorry, i cant test it now but later i’ll test it and tell you if it works

it worked, was it just simplify the script? or was the spawn function thing wrong?

1 Like