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

Loading items in local script from folder in Players?

Asked by 5 years ago
for i,v in pairs(game.Players.LocalPlayer:WaitForChild("Inventory"):GetChildren()) do

    if game.Players.LocalPlayer.Inventory:FindFirstChild(v) ~= nil then

    game.Players.LocalPlayer.Inventory[v]:Clone().Parent = script.Parent

    end
end

I get no errors at all but it doesn't load the players items into the GUI.

1 answer

Log in to vote
0
Answered by
yHasteeD 1819 Moderation Voter
5 years ago
Edited 5 years ago

Use local script and you can create a variable for player, not use game.Players.LocalPlayer.Inventory[v]:Clone().Parent = script.Parent the correct is v:Clone().Parent = script.Parent Try it:

repeat wait() until game.Players.LocalPlayer
local plr = game:GetService("Players").LocalPlayer
local inv = plr:FindFirstChild("Inventory")

for i,v in pairs(inv:GetChildren()) do
    if v ~= nil then
        v:Clone().Parent = script.Parent
    end
end
Ad

Answer this question