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

How does one insert Backpack items into a string?

Asked by 10 years ago

A while back I asked a question on how I could save a Player's backpack items, and people suggested that I inserted them into a String. The only problem is that I have no idea how to use Strings at all. I tried reading the Wiki, but the Wiki's string article is just confusing, and explains the useless things as opposed to things like this. Thanks!

1 answer

Log in to vote
-1
Answered by
RedCombee 585 Moderation Voter
10 years ago

To insert something into a string, I'm assuming that you are looking for a method of storing the names of the tools a player had into a string so they can load them up again.

I like to use Data Persistence because the ROBLOX wiki has a fairly poor explanation of how DataStores work.

You would do this like so: (Not tested)

game.Players.PlayerRemoving:connect(function(player) -- When a player leaves the game
tools = player.Backpack:GetChildren()
for i = 1, #tools do -- Getting all the tools in their backpack
player:SaveString("Tool"..i, v.Name) -- Saving the name of the tool
for i,v in pairs(player.Character:GetChildren()) do
if v:IsA("Tool") then -- Getting tool in character if there is one
player:SaveString("Tool"..i+1,v.Name)  -- Saving the name of the tool
end
end
end
end)
0
I know what a String is, I just don't know how to insert things into a String. SlickPwner 534 — 10y
0
You said you didn't know how to use strings. RedCombee 585 — 10y
0
I don't know how to use them at an advanced level, I completely understand what you explained. SlickPwner 534 — 10y
0
Does my solution work? RedCombee 585 — 10y
View all comments (4 more)
0
I have no way to test it. How would I use your way to also load the player's backpack back in when the join? SlickPwner 534 — 10y
0
Want me to post the whole script? RedCombee 585 — 10y
0
Yes, that would be lovely. SlickPwner 534 — 10y
0
Oh, and if you add it, add it in a new answer please, so I get it in my notifications. SlickPwner 534 — 10y
Ad

Answer this question