Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why won't roblox create/move a folder to player character?

Hello! I've been trying to make an inventory script (with slots for wearing items) and there are 2 slots for weapons which are named "Weapon1" and "Weapon2". They weren't working in online mode because i was creating them locally (I have filtering enabled) and the server didn't see it, so i moved the code that creates them to a serverside script and im completely baffled.

local weps = {"Weapon1","Weapon2"}

Players.PlayerAdded:connect(function(plyr)
	---OTHER STUFF---
	for i,v in pairs(weps) do
		print("weps")
		local c = Instance.new("Folder",plyr.Character)
		c.Name = v
		if c then
		print(c.Name) end
	end
	----OTHER STUFF----
end)

So, for some reason c exists (because it prints the name of c) but the folders aren't inside the character, I changed the destination to workspace and it created the folders. Like this:

local c = Instance.new("Folder",workspace)

The folders actually appear in the workspace but when i change the destination to the character like this:

local c = Instance.new("Folder",workspace)
c.Parent = plyr.Character

The folders are just nowhere. I have NO idea how the heck this happening...

2 comments

0

Shouldn't you use for _,plr in ipairs

0

where's the script?

2 answers

I solved it.. It was creating the folders before the character was actually created.

1 comment

0

??

You do not need the PlayerAdded event. Just use an LocalScript on StarterPlayerScripts (at starterPlayer)

local weps = {"Weapon1","Weapon2"}

for i,v in pairs(weps) do
        print("weps")
        local c = Instance.new("Folder",game.Players.LocalPlayer.Character) -- gets the character and inserts the folders
        c.Name = v
		if c then
        	print(c.Name)
		end
end

It does not need anything to run. It runs once a player appears.

2 comments

0

You completely missed the point, it doesn't work if i create it locally.

0

i just tested it

This discussion is preserved as it was. New answers, comments, and votes are closed.