iDemum
|
  |
| Joined: 17 Jan 2010 |
| Total Posts: 56 |
|
|
| 20 Jul 2014 06:12 PM |
Hello, I have a script test, that uses data persistence, so when a user clicks it then rejoins, it clones it and makes it 2 points above the original block. So what I need help with is for someone to change that so it will save there inventory, so if they pick up a weapon and click it then rejoin they will still have the weapon. Here is the code. Ill add comments where you have to change it . Thanks.
local Brick = script.Parent local Key = "Part" local Message = Instance.new("Message") game.Players.PlayerAdded:connect(function(Player) Player:WaitForDataReady() local Object = Player:LoadInstance(Key) if (Object ~= nil) then Object.Parent = game.Workspace Object.Anchored = true Object.CFrame = CFrame.new(Brick.Positin+Vector3.new(0,2,0)) --this line above makes it another brick and saves. Message.Text = "Success" Message.Parent = game.Workspace wait(5) Message:Remove() end end)
game.Players.PlayerRemoving:connect(function(Player) Player:SaveInstance(Key, Brick)
Thanks! end) |
|
|
| Report Abuse |
|
|
| |
|
|
| 20 Jul 2014 06:14 PM |
| Also, in future you should use F9 (online output) |
|
|
| Report Abuse |
|
|
iDemum
|
  |
| Joined: 17 Jan 2010 |
| Total Posts: 56 |
|
| |
|
iDemum
|
  |
| Joined: 17 Jan 2010 |
| Total Posts: 56 |
|
|
| 20 Jul 2014 06:16 PM |
| But I still need to change it, so I don't really need that part. |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2014 06:17 PM |
| But had you opened the output, you would have seen the error and corrected it ;) |
|
|
| Report Abuse |
|
|
iDemum
|
  |
| Joined: 17 Jan 2010 |
| Total Posts: 56 |
|
|
| 20 Jul 2014 06:23 PM |
| Well you can only test it in Play mode, so I couldn't test for errors. xD |
|
|
| Report Abuse |
|
|
| |
|
iDemum
|
  |
| Joined: 17 Jan 2010 |
| Total Posts: 56 |
|
|
| 20 Jul 2014 06:28 PM |
| Ok, well I need a real script help now xD I didn't need fixes I need what I asked xD xD |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2014 06:29 PM |
i have a script that does this and it saves ur backpack for when u respawn
easy to make |
|
|
| Report Abuse |
|
|
|
| 20 Jul 2014 06:33 PM |
Oh, right.
Don't save their weapon's Instance, as that will eat your data cost.
Instead store all the names of the weapons in a table, like so:
local weapons = {} for i, v in next, player.StarterGear:GetChildren() do weapons[i] = v.Name end
and then use HttpService:JSONEncode(string) to encode it into a string and use SaveString, then use LoadString and HttpService:JSONDecode(string) to get the table back, then iterate through it and clone the weapons from ServerStorage into their Backpack/StarterGear. |
|
|
| Report Abuse |
|
|