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: How do I add a server script to every Player?

Previous Thread :: Next Thread 
VilgO is not online. 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
Wunder_Wulfe is not online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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 is not online. 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
Wunder_Wulfe is not online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
21 Sep 2016 01:40 PM
game.PlayerAdded:connect(function(player)
--run things for player
end)
Report Abuse
jordan0810 is not online. jordan0810
Joined: 03 Jun 2012
Total Posts: 846
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 is not online. 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
Wunder_Wulfe is not online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
21 Sep 2016 02:54 PM
local playerdata = {}

--adding data
playerdata[tostring(player.UserId)]= {"hi"}

--getting data
playerdata[tostring(player.UserId)]
Report Abuse
VilgO is not online. 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
Wunder_Wulfe is not online. Wunder_Wulfe
Joined: 13 Sep 2016
Total Posts: 8356
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 is not online. 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
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