Unable To Define PlayerScripts?
Here is my code:
01 | script.Parent.Touched:Connect( function (hit) |
02 | if script.Parent.Working.Value = = false then |
03 | if hit.Parent:FindFirstChild( "Humanoid" ) then |
04 | script.Parent.Working.Value = true |
05 | local player = hit.Parent |
06 | local Player = game.Players:FindFirstChild(player.Name) |
07 | local Humanoid = player.Humanoid |
08 | local PlayerScripts = Player:FindFirstChild( "PlayerScripts" ) |
09 | local PlayerModule = PlayerScripts:FindFirstChild( "PlayerModule" ) |
10 | local Controls = PlayerModule:GetControls() |
12 | Humanoid:MoveTo(script.Parent.Parent.TargetPoint.Position) |
15 | script.Parent.Working.Value = false |
Currently when I touch the part, it gives me the error: ** 10:00:08.135 - Workspace.Detector.TouchPart.Script:9: attempt to index local 'PlayerScripts' (a nil value)
10:00:08.136 - Stack Begin
10:00:08.136 - Script 'Workspace.Detector.TouchPart.Script', Line 9
10:00:08.136 - Stack End **
If you know why I cannot define the PlayerScripts, please help. Thank you!