|
| 09 Jul 2017 10:34 PM |
Recently local player hasn't been working for me my script: game.Players.LocalPlayer and it says that's a nil value
|
|
|
| Report Abuse |
|
|
|
| 09 Jul 2017 10:42 PM |
| local player = game.Players.LocalPlayer |
|
|
| Report Abuse |
|
|
edenDeden
|
  |
| Joined: 29 Jul 2016 |
| Total Posts: 370 |
|
|
| 09 Jul 2017 10:57 PM |
make sure u using a LOCAL script for a LOCAL player
|
|
|
| Report Abuse |
|
|
|
| 10 Jul 2017 10:28 AM |
Well my script clones a UI when somebody sits in a vehicle seat then when you jump out of the seat it removes the UI and to remove that ui I need to use local player in a normal script
|
|
|
| Report Abuse |
|
|
|
| 10 Jul 2017 11:00 AM |
LocalPlayer isn't a magical force that can find exactly who you need. Each player has their own LocalScripts, and so the LocalScripts specific to them can access LocalPlayer because it knows who it is. In a Script, it runs on the server rather than a player's computer. There is know way for it to know what you mean, because there is no associated player.
You need to find another way. Maybe use game.Players:GetPlayerFromCharacter(Theircharacter)?
|
|
|
| Report Abuse |
|
|
|
| 10 Jul 2017 02:06 PM |
I found a way to sorta fix it but what i was doing was if you sit in a vehicle seat you will get a gui but to make it work I had to make it check if I was in the game if i am it will make the gui pop up on my screen ONLY which isn't what I want
|
|
|
| Report Abuse |
|
|
|
| 10 Jul 2017 04:04 PM |
LocalPlayer should be used in a LocalScript, the reason why: Because it is running on a client it knows what Local player you mean, in a script, you may be doing like this
Example when touching a brick then the leaderstats will change by +1 on bricks --Inside a script inside the brick script.Parent.Touched:connect(function(hit) h = hit.Parent:FindFirstChild("Humanoid") if h then --hit.Parent.Name is a string and can be used in WaitForChild game.Players:WaitForChild(hit.Parent.Name).leaderstats.Bricks.Value = game.Players:WaitForChild(hit.Parent.Name).leaderstats.Bricks.Value+1 end
These can be used to redirect a string to a pattern: example finding me game.Players:WaitForChild("spacesplitter") game.players:FindFirstChild("spacesplitter") game.Players["spacesplitter"] Note: the pattern '[""]' should be used if you have spaces in name or characters that is not compatible such as game.Players.space splitter--Would not work this would work game.Players["space splitter"]--this is the right code
|
|
|
| Report Abuse |
|
|
|
| 10 Jul 2017 04:23 PM |
Yeah I know... I'm saying i have no choice but to use a script
|
|
|
| Report Abuse |
|
|
|
| 10 Jul 2017 04:24 PM |
I tried to help you but, you didn't say if i helped you or not
ÄÄÄÄÄHHHHHHH
|
|
|
| Report Abuse |
|
|
|
| 10 Jul 2017 07:02 PM |
You helped for a tool i'm making which didn't work if you input a player name because nobody has a "working" name
|
|
|
| Report Abuse |
|
|