InventoryTest
LocalScript

-- FOR THE PLAYER INVENTORY
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local DataStoreService = game:GetService("DataStoreService"):GetDataStore("Test")
local ServerScriptService = game:GetService("ServerScriptService")
local ServerStorage = game:GetService("ServerStorage")
local ReplicatedFirst = game:GetService("ReplicatedFirst")

local Data = {}
local key = "user_" .. player.UserId

local Events = ReplicatedStorage.Events
local GameSkins = ReplicatedStorage.Skins
local SetCamera = Events.SetCamera
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local data = player:WaitForChild("Data")
local inventory = data:WaitForChild("Inventory")
local skins = inventory:WaitForChild("Skins")

local Inventory = script.Parent
local Main = Inventory.MainFrame
local Scroll = Main.ScrollingFrame
local Content = Scroll.Content

for i, item in pairs(skins:GetChildren()) do
    DataStoreService:GetAsync(key, HttpService:JSONDecode(Data[player]["Skin"], Data[player]["SkinInv"]))
    
    if item.Name == GameSkins:GetChildren().Name then
        if item:FindFirstChild("Owned").Value then
            if item:FindFirstChildOfClass("Humanoid") then
                local ViewportFrame = Instance.new("ViewportFrame")
                ViewportFrame.Parent = Content
                ViewportFrame.Name = item.Name .. "_VF"
                ViewportFrame.BackgroundTransparency = 1

                local Button = Instance.new("TextButton")
                Button.Parent = ViewportFrame
                Button.Position = UDim2.new(0, 0, 1, 0)
                Button.Size = UDim2.new(1, 0, 0, 15)
                Button.BorderSizePixel = 0
                Button.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
                Button.Text = "Equip"
                Button.TextScaled = true

                local Preview = item:Clone()
                Preview.Parent = ViewportFrame
                Preview.Name = item.Name .. "_VFprev"

                local Camera = Instance.new("Camera")
                Camera.Parent = ViewportFrame
                Camera.CFrame = Preview.Head.CFrame + Preview.Head.CFrame.LookVector * 5
                Camera.CFrame = CFrame.new(Camera.CFrame.Position, Preview.Head.Position)
                Camera.Name = item.Name .. "_CMprev"

                ViewportFrame.CurrentCamera = Camera

                Button.MouseButton1Down:Connect(function()
                    script.Parent.Enabled = false
                    local NewCharacter = item:Clone()
                    local CurrentCharacter = character
                    local LocalScripts = {}

                    data.Skin.Value = item.Name
                    data.Skin.Sleeve.Value = "v_" .. item.Name

                    for i2, item2 in pairs(game.StarterPlayer.StarterCharacterScripts:GetChildren()) do
                        if item2:IsA("LocalScript") then
                            table.insert(LocalScript, item2:Clone())
                        else
                            item2:Clone().Parent = NewCharacter
                        end
                    end

                    CurrentCharacter.Health:Clone().Parent = NewCharacter
                    table.insert(LocalScripts, CurrentCharacter.Animate:Clone())
                    NewCharacter.Parent = workspace
                    character = NewCharacter

                    for i3, item3 in pairs(LocalScripts) do
                        item3.Parent = NewCharacter
                    end

                    SetCamera:FireClient(player, NewCharacter.Humanoid)

                    local connection

                    local function Died()
                        wait(game.Players.RespawnTime)
                        player:LoadCharacter()
                        script.Parent.Enabled = true
                        if connection then
                            connection:Disconnect()
                        end
                    end

                    connection = NewCharacter.Humanoid.Died:Connect(Died)

                    DataStoreService:SetAsync(key, HttpService:JSONEncode(Data[player]["Skin"]))
                end)
            else
                warn("Invalid skin")
            end
        else
            print("Skin not owned")
        end
    else
        warn("No skin found")
    end
end

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: