|
| 16 Oct 2016 01:42 PM |
I need help! [CODE] local player = game.Players.LocalPlayer.Character player:MoveTo(game.Workspace.Spawn.Position) player:MoveTo(game.Workspace.Spawn.Position) function hover() print("um>") for i= 1, 10 do script.Parent.BorderSizePixel = script.Parent.BorderSizePixel +1 wait(0.1) end end function nothover() for i= 1,10 do script.Parent.BorderSizePixel = script.Parent.BorderSizePixel -1 wait(0.1) end end function click() script.Parent.Visible = false game.Workspace.CurrentCamera.CameraType = Enum.CameraType.Custom player:MoveTo(game.Workspace.SpawnG.Position) end script.Parent.MouseButton1Click:connect(click) script.Parent.MouseLeave:connect(nothover) script.Parent.MouseEnter:connect(hover) [Error] Players.Player2.PlayerGui.ScreenGui.TextButton.LocalScript:2: attempt to index local 'player' (a nil value) Also this is a local script i dont understand why its not working |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2016 02:29 PM |
For anyone stuck with is Its just because player was just too quickly defined so what i would do i local player = game.Players:WaitForChild("LocalPlayer").Character
or just add a simple wait such as wait(0.1) |
|
|
| Report Abuse |
|
|
Askadaf
|
  |
| Joined: 14 Oct 2016 |
| Total Posts: 39 |
|
|
| 30 Dec 2016 02:32 PM |
local player = game.Players.LocalPlayer repeat wait() until player.Character local char = player.Character |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2016 02:35 PM |
i'll do you one better
local player=game.Players.LocalPlayer.CharacterAdded:Wait()
|
|
|
| Report Abuse |
|
|
|
| 30 Dec 2016 02:35 PM |
^ correct
The reasoning behind this is because your script is loading faster then the Character is loading. So when the script looks for the Character, the script crashes.
Then the Character loads.
His line will tell the script to loop itself until the Character is loaded. |
|
|
| Report Abuse |
|
|
| |
|
|
| 30 Dec 2016 02:59 PM |
| I realy need help with scripting my game please help |
|
|
| Report Abuse |
|
|
|
| 30 Dec 2016 03:04 PM |
I need help with making level's and a timer
|
|
|
| Report Abuse |
|
|