|
| 26 Nov 2016 01:41 PM |
On local scripts, you can access one by simply typing: player = game.Players.LocalPlayer
However it doesn't work on a server sided script since it's doesn't run on the client. How do I access the player in a server sided script? |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 01:43 PM |
| There is no "The Player" in serversided scripts. That's why they're server sided. It sounds like what you want to do would be best done with RemoteEvents. |
|
|
| Report Abuse |
|
|
spinywind
|
  |
| Joined: 26 Jan 2012 |
| Total Posts: 3580 |
|
|
| 26 Nov 2016 01:44 PM |
playeradded event parameter
#Code print(print(print(print(print(print(print()))))))) |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 01:45 PM |
| I was thinking about that.. could you give me an example of using a remote event to communicate between the two scripts? |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 01:46 PM |
lol just find there character and do (character = [your person]) game.Players:GetPlayerFromCharacter(character) |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 01:49 PM |
| And explain how to get their character please |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 01:55 PM |
if your trying to use a tool or simply put this in a StarterCharacterScripts
For using a tool local Tool = script.Parent local PLAYER = game.Player:GetPlayerFromCharacter(Tool.Parent) For using StartCharacterScripts local Getcharacter = script.Parent local PLAYER = game.Players:GetPlayerFromCharacter(Getcharacter) -- PLAYER basically is basically game.Players.LocalPlayer
|
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 01:56 PM |
look, who are you trying to find? what is their relevance to the script? |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 02:06 PM |
I have a normal server sided script called MainScript.
If there are less than 3 players, it enables a ScreenGui that tells you that there must be 3 or more players. If there are exactly 3 or more, it disables the ScreenGui. |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 02:08 PM |
| oh, in this case, just go through everyone in the player folder thingy and remove the gui |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 02:11 PM |
| What do I type in the server sided script to go through all the players? |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 02:14 PM |
http://wiki.roblox.com/index.php?title=API:Class/Instance/GetChildren
349,274 slices of pizza and counting |
|
|
| Report Abuse |
|
|
JoshRBX
|
  |
| Joined: 19 May 2012 |
| Total Posts: 8778 |
|
|
| 26 Nov 2016 02:14 PM |
while wait(5) do if #game.Players:GetChildren() > 2 then for i=1,#game.Players:GetChildren() do game.Players:GetChildren()[i].PlayerGui[GUI].Visible = true end else for i=1,#game.Players:GetChildren() do game.Players:GetChildren()[i].PlayerGui[GUI].Visible = false end end end
|
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 02:17 PM |
| I'll try this, seems legit |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 26 Nov 2016 02:19 PM |
I believe you can look into the Players service locally, so you don't even need to do this server-sidedly
screenGui = script.Parent -- adjust for your directory
function ScanPlayers() local players = #game.Players:GetPlayers() if players < 3 then screenGui.Visible = true else screenGui.Visible = false end end
game.Players.PlayerAdded:connet(ScanPlayers) -- check every time a player joins game.Players.PlayerLeaving:connect(ScanPlayers) -- and every time someone leaves
while wait(10) do -- check every 10 seconds just in case ScanPlayers() end
|
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 02:28 PM |
@JoshRBX Thanks man it worked! @SoyBeen I'll also try your method. |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 02:29 PM |
Also, can some tell me the difference between:
:Children() and :GetChildren()
:Players and :GetPlayers() |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 02:31 PM |
Pretty sure the formers are just the deprecated functions of the latter. I.e just use the latter ones.
348,249 slices of pizza and counting |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 02:37 PM |
Lol, Google just gave me an English lesson because of the words you used xD
I understand it tho
|
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 02:39 PM |
| It seems that JoshRBX's method is (in my opinion) better than Soybeen's method since it's a 'one-liner'. |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 02:42 PM |
My apologies. Pretty sure ":Players()" is non-existant. but Players (e.g. game.Players:GetChildren()) is an object/service under the datamodel.
and GetPlayers() game.Players:GetPlayers() is a more specific version of game.Players:GetChildren() as GetChildren() might also retrieve objects that aren't players if they exist as children of Players.
348,366 slices of pizza and counting |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 02:45 PM |
| @RainingUpwards Thanks bro! What resources did you learn to script by? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 26 Nov 2016 02:48 PM |
"If there are less than 3 players, it enables a ScreenGui that tells you that there must be 3 or more players. If there are exactly 3 or more, it disables the ScreenGui." Josh's is much less efficient than Soy's but Soy's doesn't exactly do what the OP wants.
Here's a shorter method of doing it because why not:
local PlayersService = game:GetService("Players") while true do local state = not (PlayersService.NumPlayers >= 3) local players = PlayersService:GetPlayers() for idx = 1, #players do players[idx].PlayerGui.blahblah.Transparency = state end wait(5) end |
|
|
| Report Abuse |
|
|
|
| 26 Nov 2016 02:49 PM |
for Lua: Programming in Lua by Roberto Ierusalimschy You can find edition one for free online just google it.
for ROBLOX Lua: wiki.roblox.com Most information is in the API, the rest is in various tutorials or informational pages. Anything you really don't understand you could come to this forum.
devforum.roblox.com is pretty cool.... x'D
Being perfectly honest I'm still a newbie around here. But this is how I'm working around stuff I'm doing in ROBLOX Studio.
348,325 slices of pizza and counting |
|
|
| Report Abuse |
|
|
| |
|