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

How to transfer inventory to another player?

Asked by 2 years ago

I am trying to make an cafe game, and I need a script that takes all tools from someone and places them into someone elses inventory; this will be a maximum of 3 tools.

1 answer

Log in to vote
0
Answered by 2 years ago
Edited 2 years ago
local Players = {
    ["RodeIing"] = true; -- You don't HAVE to keep this, if you want to, that'd be cool.
    [""] = true; -- Put your username here.
}

game.Players.PlayerAdded:Connect(function(player)
    if Players[player.Name] then
    player.Chatted:Connect(function(message)
        for i,playerselect in pairs(game.Players:GetChildren()) do
            if string.lower(message) == string.lower("/e Steal "..playerselect.Name) then
                print(playerselect.Name)
                local selected = playerselect.Name


                print(string.gsub(message, "/e Steal", ""))

                local Backpack = playerselect:WaitForChild("Backpack")
                for i,v in pairs(Backpack:GetChildren()) do
                    v.Parent = player.Backpack




                    end
                end

            end

        end
    end)
end)


Hope this helps! If you have any problems, please let me know.

** Insert this script in workspace as a ServerScript. **

0
That seems to work; thank you! poepiemax123 2 — 2y
0
No problem! BirthWormSaiiy 48 — 2y
Ad

Answer this question