PastDays
|
  |
| Joined: 09 Jan 2011 |
| Total Posts: 732 |
|
|
| 07 Dec 2016 04:31 PM |
Why does this script give this error?
----------------------------------------------------------- 22:29:43.124 - Workspace.Part Counter:3: attempt to index field 'LocalPlayer' (a nil value) ----------------------------------------------------------- local count = workspace -- The place where to count bricks
local Display = game.Players.LocalPlayer.PlayerGui.FPS.Frame.Amount.Text
function CountBricks() local c = 0 for i,v in pairs(count:GetChildren()) do if v:IsA("BasePart") then c = c + 1 end end return c end
while true do Display.Text = "There are "..CountBricks().." Bricks." wait(0.0001) end
|- PastDays -| |
|
|
| Report Abuse |
|
|
|
| 07 Dec 2016 04:33 PM |
| Are you running this through a localscript or server script? |
|
|
| Report Abuse |
|
|
PastDays
|
  |
| Joined: 09 Jan 2011 |
| Total Posts: 732 |
|
|
| 07 Dec 2016 04:35 PM |
Normal script (Server script) in workspace
|- PastDays -| |
|
|
| Report Abuse |
|
|
PastDays
|
  |
| Joined: 09 Jan 2011 |
| Total Posts: 732 |
|
|
| 07 Dec 2016 04:38 PM |
Nvm Fixed it
|- PastDays -| |
|
|
| Report Abuse |
|
|
|
| 07 Dec 2016 04:39 PM |
| You cannot use localplayer inside a serverscript since its running in a server. Instead you need to use GetPlayers function to get the players or use a local script instead. |
|
|
| Report Abuse |
|
|
PastDays
|
  |
| Joined: 09 Jan 2011 |
| Total Posts: 732 |
|
|
| 07 Dec 2016 04:39 PM |
I realised i had done that after i posted. Thanks for helping anyway.
|- PastDays -| |
|
|
| Report Abuse |
|
|