VilgO
|
  |
| Joined: 15 Feb 2011 |
| Total Posts: 518 |
|
|
| 21 Sep 2016 01:28 PM |
| So we have StarterPlayerScripts, but we can't use it to insert a copy of a Script into every Player when they join the server. Is there some other way to do this without explicitly subscribing to PlayerAdded? |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2016 01:29 PM |
| you answered your own question and you don't really have a reason to do this since you can run seperate threads for each player until they do not have a parent |
|
|
| Report Abuse |
|
|
Quebankus
|
  |
| Joined: 25 Aug 2011 |
| Total Posts: 846 |
|
|
| 21 Sep 2016 01:31 PM |
Put the script in a localscript? Get the localscript to disable and reenable the script to reset it? |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2016 01:40 PM |
game.PlayerAdded:connect(function(player) --run things for player end) |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2016 01:59 PM |
local repStorage = game:GetService("ReplicatedStorage") local scriptToGiveName = "PlayerScript" game.PlayerAdded:connect(function(plr) if repStorage:FindFirstChild(tostring(scriptToGiveName)) then local scriptToGive = repStorage:WaitForChild(tostring(scriptToGiveName),3):clone() if plr:FindFirstChild("PlayerScripts") then scriptToGive.Parent = plr:WaitForChild("PlayerScripts",3) scriptToGive.Disabled = false end else print("You forgot to put the script in replicated storage with the correct name") break end end)
|
|
|
| Report Abuse |
|
|
VilgO
|
  |
| Joined: 15 Feb 2011 |
| Total Posts: 518 |
|
|
| 21 Sep 2016 02:51 PM |
| To avoid spamming with separate threads, here's a new question: how do I attach a table to a Player? Is there a way other than creating a global table that holds every player's data? |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2016 02:54 PM |
local playerdata = {}
--adding data playerdata[tostring(player.UserId)]= {"hi"}
--getting data playerdata[tostring(player.UserId)] |
|
|
| Report Abuse |
|
|
VilgO
|
  |
| Joined: 15 Feb 2011 |
| Total Posts: 518 |
|
|
| 21 Sep 2016 02:58 PM |
Sigh. Roblox really needs a better API.
Is there a reason for using tostring(player.UserId) instead of just player.UserId? |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2016 03:05 PM |
because you want to store it as a string so that it is a dictionary and not an array and user id so when name changes occour data is not lost |
|
|
| Report Abuse |
|
|
VilgO
|
  |
| Joined: 15 Feb 2011 |
| Total Posts: 518 |
|
|
| 21 Sep 2016 03:14 PM |
| Why is it better to use the table as a dictionary and not an array? It's the same data structure in both cases, right? It won't waste space on all the numbers between 0 and player.UserId, will it? |
|
|
| Report Abuse |
|
|