Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I make a death event do this?

I need a event happen when a person dies, and it teleports objects from a inventory gui to workspace, does anyone know how? If you need the script sample here it is :D :

`game.Players.LocalPlayer.Character.Humanoid.Died:connect(function(ondeathy)
if game.ReplicatedStorage:FindFirstChild(stuff[x].Value) then
local xxx = game.ReplicatedStorage:FindFirstChild(stuff[x].Value)
for i, v in ipairs(game.ReplicatedStorage:GetChildren()) do
	if v.Name == stuff[x].Value then
		v.Parent = Workspace
v:MoveTo(game.Players.LocalPlayer.Character.Torso.Position + Vector3.new(math.random(1,3),0,math.random(1,3)))
	end



end end	end)`

the value x is 1, 16 and stuff is all of the slot values :D

4 answers

✓ Accepted answer

repeat wait() until game.Players.LocalPlayer and game.Players.LocalPlayer.Character
local p = game.Players.LocalPlayer
local c = p.Character
local h = c:WaitForChild("Humanoid")
local storage = game.ReplicatedStorage["Folder"] --folder with items
local playerInventory = p.PlayerGui["Inventory"] --Wherever you're putting the player's inventory

h.Died:connect(function()
	for i,v in pairs(playerInventory:GetChildren()) do 
		local storageItem = storage:findFirstChild(v.Name)
		if storageItem then 
			print("Dropped "..v.Name)
			clo = storageItem:Clone()
			clo.Handle.CFrame = c.Torso.CFrame +
Vector3.new(math.random(-5,5),0,math.random(-5,5))
			clo.Parent = Workspace
		end
	end
end)

Did you check the output?

2 comments

0

It doesn't say anything

0

Please do not dedicate entire answers to this. Earn the ability to comment and reserve those to do these sorts of replies instead.

I am a bit confused on the question. Are you asking us to debug your code, or to right you a new one? Or to explain the code you gave?

6 comments

0

I need someone to debug and explain

0

Well, then we will need the whole code. I can barely understand any of this, and if you don't want to release the whole code, then please PM me on ROBLOX

0

Alright :P

0

I sent it

0

Please do not dedicate entire answers to this. Earn the ability to comment and reserve those to do these sorts of replies instead.

0

I was stuck between two prediciments; A.) Post that, and be able to help or B.) Not help at all. I made the choice of A, but I understand, and hopefully next time I will at least attempt to somewhat give an answer.

This discussion is preserved as it was. New answers, comments, and votes are closed.