generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Cloning into backpack

Previous Thread :: Next Thread 
TheAlaska is not online. 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
pinballboy7 is not online. pinballboy7
Joined: 12 Mar 2009
Total Posts: 1485
01 Mar 2016 07:45 PM
Why is the item in Lighting??
Report Abuse
TheAlaska is not online. 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
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
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
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
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 is not online. 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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
01 Mar 2016 08:01 PM
He did make a mistake. Replace "clone" with "item".


Report Abuse
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
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 is not online. 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 is not online. 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
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
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
masterblokz is not online. masterblokz
Joined: 17 Nov 2010
Total Posts: 9517
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image