SpxdersJoin Date: 2012-11-02 Post Count: 910 |
Does anyone know how to script when a player dies their backpack items drop where they died? |
|
|
game.Players.PlayerAdded:connect(function(player)
while not player.Character do wait() print("no character") end
player.Character.Humanoid.Died:connect(function()
local torsoCFrame = player.Character.Torso.CFrame
for i,v in pairs(player.Backpack:GetChildren()) do
if v:IsA("Tool") then -- final check
v.Parent = game.Workspace
v.Handle.CFrame = torsoCFrame
end
end
end)
end)
havent tested it out yet. probably going to be wrong cause i suck at scripting |
|
|
local function onPlayerAdded(player)
local function onCharacterAdded(char)
local backpack = player:WaitForChild("Backpack")
local humanoid = char:WaitForChild("Humanoid")
local torso = char:WaitForChild("Torso")
local function onDied()
for _,v in pairs(char:GetChildren()) do
if v:IsA("Tool") then
if v.RequiresHandle and v.CanBeDropped and v:FindFirstChild("Handle") then
v.Parent = workspace
end
break
end
end
for _,v in pairs(backpack:GetChildren()) do
if v:IsA("Tool") and v.RequiresHandle and v.CanBeDropped then
local handle = v:FindFirstChild("Handle")
if handle then
v.Parent = workspace
handle.CFrame = torso.CFrame
end
end
end
end
humanoid.Died:connect(onDied)
end
if player.Character and player.Character:IsDescendantOf(workspace) then
onCharacterAdded(player.Character)
end
player.CharacterAdded:connect(onCharacterAdded)
end
for _,v in pairs(game.Players:GetPlayers()) do
onPlayerAdded(v)
end
game.Players.PlayerAdded:connect(onPlayerAdded) |
|
SpxdersJoin Date: 2012-11-02 Post Count: 910 |
Ill try both. |
|
TimeTicksJoin Date: 2011-04-27 Post Count: 27115 |
Jesus clonetrooper...why would you ever write that many lines of code?
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(char)
char.Humanoid.Died:connect(function()
for i,v in next, char:GetChildren() do
if v:IsA("Tool") then
v.Parent = workspace
v.Handle.CFrame = char.Torso.CFrame
end
end
end)
end)
end) |
|
|
|
TimeTicksJoin Date: 2011-04-27 Post Count: 27115 |
@Above no its not |
|
SpxdersJoin Date: 2012-11-02 Post Count: 910 |
Guys, When the player doesnt have the tool equipeed it doesnt drop, Is there a way to do this. |
|
NotwalJoin Date: 2014-12-31 Post Count: 915 |
This had better not have anything to do with minecraft.... please let it be something original.
ץ๏ย ς๏ยl๔ภ't ђคภ๔lє ๓є єשєภ เŦ เ ςค๓є ฬเtђ เภรtгยςtเ๏ภร. |
|
SpxdersJoin Date: 2012-11-02 Post Count: 910 |
|
|
|
i made something like this a while back, and i made a model of it:
WARNING: TRASHY OLD SCRIPTS
http://www.roblox.com/Drop-tools-on-death-item?id=386749238
┬┴┬┴┤( ͡° ͜ʖ├┬┴┬┴ hello kids |
|
|
did my model help?
┬┴┬┴┤( ͡° ͜ʖ├┬┴┬┴ hello kids |
|
SpxdersJoin Date: 2012-11-02 Post Count: 910 |
let me see |
|
SpxdersJoin Date: 2012-11-02 Post Count: 910 |
no, Do i have to put it in gui? |
|
|
ye
┬┴┬┴┤( ͡° ͜ʖ├┬┴┬┴ hello kids |
|
SpxdersJoin Date: 2012-11-02 Post Count: 910 |
YESSS ICEKILLER KISSS ME UR SO GOOD
ehem, I mean thank you. |
|
|
i'm surprised it still works after all of these months because i used many old school methods for scripting :P
and you're welcome
┬┴┬┴┤( ͡° ͜ʖ├┬┴┬┴ hello kids |
|
|
@TimeTicks
Its just a persistent style I follow.
|
|