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: Getting LocalPlayer from a Server Script?

Previous Thread :: Next Thread 
R0Y8 is not online. 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
foreverpower is not online. foreverpower
Joined: 05 Feb 2011
Total Posts: 5578
29 Aug 2015 12:42 PM
There is no localplayer in a server script.
Report Abuse
Ripepperoni is not online. Ripepperoni
Joined: 04 Jul 2010
Total Posts: 5715
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 is not online. 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 is not online. 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 is not online. Darkenus
Joined: 17 Jul 2014
Total Posts: 1997
29 Aug 2015 12:54 PM
game.Players.R0Y8
Report Abuse
East98 is online. 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 is not online. 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 is not online. 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
Ripepperoni is not online. Ripepperoni
Joined: 04 Jul 2010
Total Posts: 5715
30 Oct 2015 07:26 PM
ur an idiot
Report Abuse
Luxurize is not online. 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
IllegallyBlind is not online. IllegallyBlind
Joined: 07 Nov 2010
Total Posts: 1691
30 Oct 2015 07:37 PM
if u really want it then use a remote function


i make u math.sqrt()
Report Abuse
AuroJosh is not online. 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 is not online. 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 is not online. 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
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
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 is not online. 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
lazycoolboy500 is not online. lazycoolboy500
Joined: 26 Jul 2011
Total Posts: 55
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
lazycoolboy500 is not online. lazycoolboy500
Joined: 26 Jul 2011
Total Posts: 55
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
ComradeREKTangle is online. ComradeREKTangle
Joined: 07 Feb 2010
Total Posts: 850
23 May 2016 09:46 PM
for i,v in pairs(game.Players:GetPlayers()) do
v is the player
end
Report Abuse
exoSentinel is not online. exoSentinel
Joined: 18 Mar 2012
Total Posts: 2795
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 is not online. ElectroTM
Joined: 23 Nov 2012
Total Posts: 1135
23 May 2016 09:57 PM
^


y-you too...
Report Abuse
Isosta is not online. 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 is not online. Syntropy
Joined: 16 Mar 2009
Total Posts: 2272
23 May 2016 11:22 PM
*Thread is irrelevantly from 2015*
Report Abuse
Ben1925 is not online. 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
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