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
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?
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?