leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
|
| 11 Jul 2016 12:10 AM |
| I have a shop system in place for an upcoming project and I wanted to know where I can store any weapons a player has bought and the weapon he has equipped so that when the round starts the weapon is cloned to the backpack so the play can use. My question is where can I store this for every player to have there own folder that has all there weapons/stuff when they join the game? |
|
|
| Report Abuse |
|
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
| |
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
| |
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
| |
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
| |
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
| |
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
| |
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
| |
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
| |
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
| |
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
|
| 11 Jul 2016 01:57 AM |
| bump #10 Officially considered spam.. |
|
|
| Report Abuse |
|
|
|
| 11 Jul 2016 02:26 AM |
I'll just help you out with this. So first of all, we'll need a Server script to store everyone's data. Let's create a table:
local SessionData = {}
Now we want players to have their own table when they join the game. We can make a tables inside this table for them when they join.
game:GetService("Players").PlayerAdded:connect(function(newPlr) SessionData[newPlr.Name] = {} end)
Now we can create a function to update their data whenever they buy something:
function UpdatePlrData(Plr, Value) table.insert(SessionData[Plr.Name], Value) end
You can now use this function whenever someone buys a weapon. Beware that, if they buy the weapon twice, they'll get it twice so you may need to tweak that. You can store the name of the gun.
Now we want to give everyone their weapons. Assuming that the guns are stored in ServerStorage, we can create a function:
function EquipPlrs() for i,v in pairs(game:GetService("Players"):GetChildren()) do for i2,v2 in pairs(SessionData[v.Name]) do game:GetService("ServerStorage"):FindFirstChild(v2):Clone().Parent = v.Backpack end end end
And I hope you know how to make a function to remove it once the round ends. |
|
|
| Report Abuse |
|
|
leomesa
|
  |
| Joined: 11 Apr 2014 |
| Total Posts: 1029 |
|
|
| 11 Jul 2016 01:19 PM |
| Ah ok Tables got it. Thanks so much! |
|
|
| Report Abuse |
|
|