So I’m trying to make a looting system but can’t seem to figure it out. The first thing I want to do is spawn a backpack the second the player dies. After that, I want to create a folder, move the folder to replicatedstorage, then clone all the tools from the player’s backpack into the folder in replicatedstorage. once the player triggers the proximity prompt a sound will play. Once the sound is finished playing, I will clone all the tools in the folder to workspace in a specific position near where the player’s backpack dropped.
this is what I have so far:
this first script is for the backpack spawn which I put in starterplayerscripts
local humanoid = script.Parent:WaitForChild(“Humanoid”)
local torso = script.Parent:WaitForChild(“Torso”)
local players = game.Players
humanoid.Died:Connect(function()
local backpack = script.Parent.Parent.Backpack
local items = backpack:GetChildren()
local clone1 = items:Clone()
local storage = Instance.new(“Folder”)
storage.Parent = game.ReplicatedStorage
storage.Name = “tempitems”
clone1.Parent = storage
wait()
The second script is placed in a model which is parented to replicatedstorage
there is also a proximity prompt inside of the model
local pp = game:GetService(“ProximityPromptService”)
SS = game:GetService(“ServerStorage”)
local sound = script.Parent.SearchingThroughBackpack
local proximityprompt = script.Parent.ProximityPrompt
Make a folder inside ReplicatedStorage and add the tools inside it:
local Folder = Instance.new("Folder", game.ReplicatedStorage)
Player.Character.Humanoid:UnequipTools()
for i,v in pairs(Player.Backpack:GetChildren()) do
local Object = v:Clone()
Object.Parent = Folder
end
To get Player just make a Player.Added:Connect(function(Player)) function
edit: or you can use remote events and then use a local script to check when the player dies and send it to a server script to get the player’s tools by sending the player’s name through the event.
Yea that looks perfect! All the tools will be stored inside the folder and you can just make the player get all the items from that folder and if you have a despawn thing just delete that folder.
In a local script if the player dies just make the same backpack thing drop and when you search it all the items in that folder that you saved the dead players tools drop around it.
I didn’t really wanna do this. But I think i might have to switch to a random loot table instead of trying to copy everything the player who died had. Thanks for the help though I really appreciate it!