Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by
Turgon 80
9 years ago

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...

0
Shouldn't you use `for _,plr in ipairs` unmiss 337 — 9y
0
where's the script? davness 376 — 9y

2 answers

Log in to vote
1
Answered by
Turgon 80
9 years ago

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

0
?? davness 376 — 9y
Ad
Log in to vote
0
Answered by
davness 376 Moderation Voter
9 years ago

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.

0
You completely missed the point, it doesn't work if i create it locally. Turgon 80 — 9y
0
i just tested it davness 376 — 9y

Answer this question