Answered by
5 years ago Edited 5 years ago
With local scripts, you have access to the LocalPlayer, which you can get with
2 | local plr = game.Players.LocalPlayer |
With any player instance, you can get their character with
1 | local character = plr.Character |
3 | local character = game.Players.LocalPlayer.Character |
So your code would be...
1 | local plr = game.Players.LocalPlayer |
2 | local character = plr.Character |
3 | function KeyPress(input, gameProcessed) |
4 | if input.KeyCode = = Enum.KeyCode.T then |
9 | game:GetService( "UserInputService" ).InputBegan:Connect(KeyPress) |
Unless you wanted to use workspace...
1 | local plr = game.Players.LocalPlayer |
2 | function KeyPress(input, gameProcessed) |
3 | if input.KeyCode = = Enum.KeyCode.T then |
4 | game.Workspace [ plr.Name ] .Head |
Hope this helps!