TheAlaska
|
  |
| Joined: 21 Jan 2011 |
| Total Posts: 152 |
|
|
| 01 Mar 2016 07:43 PM |
I'm trying to make a script so once someone picks an item up, it will stay in their inventory even after they die. It works the first time they die, however if they die more than once, it doesn't appear.
local clone = game.Lighting.Idol:Clone()
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) if character.Name == game.Lighting.IdolHolder.Value then clone.Parent = game.Players[character.Name].Backpack end end) end)
Can anyone help me please?
|
|
|
| Report Abuse |
|
|
|
| 01 Mar 2016 07:45 PM |
| Why is the item in Lighting?? |
|
|
| Report Abuse |
|
|
TheAlaska
|
  |
| Joined: 21 Jan 2011 |
| Total Posts: 152 |
|
|
| 01 Mar 2016 07:47 PM |
Because that's where the item being cloned is. I just need to know how to clone the item into the backpack. Thanks.
|
|
|
| Report Abuse |
|
|
|
| 01 Mar 2016 07:48 PM |
local item = game.ReplicatedStorage.Idol:Clone()
game.Players.PlayerAdded:connect(function(player) repeat wait() until player.Character ~= nil if player.Name == tostring(game.ReplicatedStorage.IdolHolder.Value) then clone:Clone().Parent = game.Players[character.Name].Backpack clone.Parent = game.Players[character.Name].StarterGear end end) |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2016 07:49 PM |
| (it's better to put things in replicatedstorage too, but you can keep it in lightning. personal preference.) |
|
|
| Report Abuse |
|
|
TheAlaska
|
  |
| Joined: 21 Jan 2011 |
| Total Posts: 152 |
|
|
| 01 Mar 2016 07:59 PM |
I'm not a very experienced scripter and you changed a ton of stuff such as ReplicatedStorage. You also reference character/clone in your script which aren't indexed. You lost me...
|
|
|
| Report Abuse |
|
|
|
| 01 Mar 2016 08:01 PM |
He did make a mistake. Replace "clone" with "item".
|
|
|
| Report Abuse |
|
|
|
| 01 Mar 2016 08:04 PM |
o lord
ok yeah, the lines that start with clone, replace the lowercase clone with item.
ReplicatedSTorage is a more "modern" way of storing things and you should move your idol things there, unless your whole place is depending on lighting, which in that case just change ReplicatedStorage to lighting |
|
|
| Report Abuse |
|
|
TheAlaska
|
  |
| Joined: 21 Jan 2011 |
| Total Posts: 152 |
|
|
| 01 Mar 2016 08:12 PM |
Ok, that makes sense. However, you also reference character, which is nowhere referenced.
local item = game.Lighting.Idol:Clone()
game.Players.PlayerAdded:connect(function(player) repeat wait() until player.Character ~= nil if player.Name == tostring(game.Lighting.IdolHolder.Value) then item:Clone().Parent = game.Players[---->character.Name<----].Backpack item.Parent = game.Players[---->character.Name<----].StarterGear end end)
|
|
|
| Report Abuse |
|
|
TheAlaska
|
  |
| Joined: 21 Jan 2011 |
| Total Posts: 152 |
|
|
| 01 Mar 2016 08:15 PM |
I got it to work. I just changed it to:
local item = game.Lighting.Idol:Clone()
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) if player.Name == tostring(game.Lighting.IdolHolder.Value) then item:Clone().Parent = game.Players[character.Name].Backpack end end) end)
It also had the issue of making two items in the backpack, so I removed the StarterGear line. Thank you for your help!
|
|
|
| Report Abuse |
|
|
|
| 01 Mar 2016 08:17 PM |
clone:Clone().Parent = player.Backpack clone.Parent = player.StarterGear
my mistake, i usually put a variable for char or character but i didn't think this was long enough for that -- but anyways,
i don't even need to do that lol
player name == character name |
|
|
| Report Abuse |
|
|
|
| 01 Mar 2016 08:18 PM |
| you don't need the characteradded event, you could keep it or just avoid it by putting it into startergear. characteradded fires when they join and everytime they respawn. startergear is there to basically make you have... starter gear everytime you respawn. glad you got it to work nonetheless |
|
|
| Report Abuse |
|
|