R0Y8
|
  |
| Joined: 13 Jul 2014 |
| Total Posts: 160 |
|
|
| 29 Aug 2015 12:37 PM |
How can I get LocalPlayer from a Server Script?
Since I can't use game.Players.LocalPlayer in a Server Script, how can I find the LocalPlayer from a Server Script?
--I have no choice but to use a Server Script. |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2015 12:42 PM |
| There is no localplayer in a server script. |
|
|
| Report Abuse |
|
|
|
| 29 Aug 2015 12:43 PM |
what would you consider a "local player" from a server script
think about your question server script >local player
wat |
|
|
| Report Abuse |
|
|
Darkenus
|
  |
| Joined: 17 Jul 2014 |
| Total Posts: 1997 |
|
|
| 29 Aug 2015 12:45 PM |
Server script runs in serverscriptservice, its PART OF THE SERVER, ITS NOT LOCAL. Its the same to EVERYONE.
|
|
|
| Report Abuse |
|
|
R0Y8
|
  |
| Joined: 13 Jul 2014 |
| Total Posts: 160 |
|
|
| 29 Aug 2015 12:54 PM |
So is there any way for me to call my player through a server script?
game Players R0Y8 <-- Ned to call that |
|
|
| Report Abuse |
|
|
Darkenus
|
  |
| Joined: 17 Jul 2014 |
| Total Posts: 1997 |
|
| |
|
East98
|
  |
| Joined: 17 Jun 2012 |
| Total Posts: 418 |
|
|
| 29 Aug 2015 01:35 PM |
| It depends what youre trying to achieve. Enlighten me on your goals and maybe i can help |
|
|
| Report Abuse |
|
|
Luxurize
|
  |
| Joined: 31 Mar 2015 |
| Total Posts: 1289 |
|
|
| 30 Oct 2015 07:10 PM |
Lol, having the same issue here.
“Insane isn't always black or white. We're all pathological, in our own ways.” |
|
|
| Report Abuse |
|
|
Luxurize
|
  |
| Joined: 31 Mar 2015 |
| Total Posts: 1289 |
|
|
| 30 Oct 2015 07:23 PM |
Lol, having the same issue here.[2]
“Insane isn't always black or white. We're all pathological, in our own ways.” |
|
|
| Report Abuse |
|
|
| |
|
Luxurize
|
  |
| Joined: 31 Mar 2015 |
| Total Posts: 1289 |
|
|
| 30 Oct 2015 07:32 PM |
No, I actually need to attain a local player using a server script. If I use a local script it won't work as intended.
“Insane isn't always black or white. We're all pathological, in our own ways.” |
|
|
| Report Abuse |
|
|
|
| 30 Oct 2015 07:37 PM |
if u really want it then use a remote function
i make u math.sqrt() |
|
|
| Report Abuse |
|
|
AuroJosh
|
  |
| Joined: 04 Oct 2015 |
| Total Posts: 484 |
|
|
| 30 Oct 2015 07:44 PM |
Use a function to get it I think.
This is what I use when a player joins the game.
game.Players.PlayerAdded:connect(function(Player)
script.Gui:Clone().Parent = Player.PlayerGui (Backpack, etc)
end)
Who is dis? Dis is AuroJosh! |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 30 Oct 2015 07:47 PM |
Let's think about this most important detail.
When is this script designed to run? When do we need the Player? Is the Player related to anything else in any way? Did they touch a part, or are they on a team? |
|
|
| Report Abuse |
|
|
Ben1925
|
  |
| Joined: 07 Apr 2011 |
| Total Posts: 741 |
|
|
| 30 Oct 2015 08:14 PM |
| Use a remote client event. Make it pass an argument that has the players name. Tada! |
|
|
| Report Abuse |
|
|
|
| 30 Oct 2015 08:23 PM |
| Please enlighten me on what a local player is to the server. Many people have asked me this same question, and I always respond it doesn't make sense. So far none of them have given me a reasonable explanation. I look forward to hearing it. |
|
|
| Report Abuse |
|
|
Ben1925
|
  |
| Joined: 07 Apr 2011 |
| Total Posts: 741 |
|
|
| 30 Oct 2015 08:26 PM |
| I think what OP is saying is get a client's player (LocalPlayer) and send it to the server. His way of saying it makes it confusing, though. As I said before you can do this with remote events so lol |
|
|
| Report Abuse |
|
|
|
| 23 May 2016 09:45 PM |
This is a simple fix. All you have to do is make a localscript to get the players name:
Player = game.Players.LocalPlayer (this goes in the localscript)
Now, create a string value somewhere in your studio, for example game.ServerStorage (name it whatever you want) and then type:
game.ServerStorage.NAME OF YOUR STRING VALUE.Value = Player.Name
After you done that put the following code in your server script(s):
PlayerName = game.ServerStorage.NAME OF YOUR STRING VALUE.Value Player = game.Players[PlayerName]
Now that all of that is gone you can now call the player from (a) server script(s)!
|
|
|
| Report Abuse |
|
|
|
| 23 May 2016 09:46 PM |
BTW I do know this thread is over a year old, but this might be helpful for any other player that needs to know this!
|
|
|
| Report Abuse |
|
|
|
| 23 May 2016 09:46 PM |
for i,v in pairs(game.Players:GetPlayers()) do v is the player end |
|
|
| Report Abuse |
|
|
|
| 23 May 2016 09:47 PM |
(If you want to use Remote Events)
From Wiki:
A Client Event will be fired in a Server Script and handled in a local script. In this example the server script will create the RemoteEvent (to avoid issues if you are using FilteringEnabled) and then wait 5 seconds before firing:
-- Inside Server Script game.Players.PlayerAdded:connect(function(player) local event = Instance.new("RemoteEvent") event.Parent = player event.Name = "MyClientEvent" wait(5) event:FireClient(player) end)
This LocalScript will print a message when the event fired from the server is recieved by the client.
-- This is inside a LocalScript. -- Place it anywhere a LocalScript can go (for example, under StarterPlayer.StarterPlayerScripts) game.Players.LocalPlayer:WaitForChild("MyClientEvent").OnClientEvent:connect(function() print("EventHappened") end)
|
|
|
| Report Abuse |
|
|
ElectroTM
|
  |
| Joined: 23 Nov 2012 |
| Total Posts: 1135 |
|
| |
|
Isosta
|
  |
| Joined: 10 May 2015 |
| Total Posts: 14729 |
|
|
| 23 May 2016 10:01 PM |
| someone doesn't know how to use remoteevents lmfaooo |
|
|
| Report Abuse |
|
|
Syntropy
|
  |
| Joined: 16 Mar 2009 |
| Total Posts: 2272 |
|
|
| 23 May 2016 11:22 PM |
| *Thread is irrelevantly from 2015* |
|
|
| Report Abuse |
|
|
Ben1925
|
  |
| Joined: 07 Apr 2011 |
| Total Posts: 741 |
|
|
| 24 May 2016 09:15 AM |
| Why the hell are you guys still talking about this? |
|
|
| Report Abuse |
|
|