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

How can I make a tool stay in someone's inventory after they die?

Asked by 4 years ago

I have a Loadout Selector GUI that gives the player the gun from the class that they choose. I'm not a pro scripter yet, so I don't know these things yet. I want to make it so that the player keeps the gun that they chose in their inventory after they die. Is there a script that will help me with this problem? Thanks.

0
Maybe a script that can go in starter player scripts or something... idk YT_LandenFN 7 — 4y
0
Place it into StarterGear. Ziffixture 6913 — 4y
0
put the item in StarterPack TheKakYTArmy 125 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

Put a folder in server storage and call it ToolsFolder any tools you want to save duplicate them and put them inside the folder then inside server script service put in a script and type this:

01local dss = game:GetService("DataStoreService")
02local toolsDS = dss:GetDataStore("ToolsData")
03 
04local toolsFolder = game.ServerStorage.ToolsFolder
05 
06game.Players.PlayerAdded:Connect(function(plr)
07 
08    local toolsSaved = toolsDS:GetAsync(plr.UserId .. "-tools") or {}
09 
10    for i, toolSaved in pairs(toolsSaved) do
11 
12        if toolsFolder:FindFirstChild(toolSaved) then
13 
14            toolsFolder[toolSaved]:Clone().Parent = plr.Backpack
15            toolsFolder[toolSaved]:Clone().Parent = plr.StarterGear
View all 40 lines...
0
Thanks you so much bro I really appreciate this. You are the best. *BTW how did u learn to script? I'm not really sure if YouTube tutorials are the way to go or not. YT_LandenFN 7 — 4y
Ad
Log in to vote
1
Answered by 4 years ago

Put the gun in starter gear not in player backpack

Answer this question