✓ Accepted answer
:FindFirstChild() accepts a string, not an object.
The Player variable is an object, because it is referring to game.Players.LocalPlayer.
So instead of this:
Human = game.Workspace:FindFirstChild(Player)
Syntactically, the correct way is this:
Human = game.Workspace:FindFirstChild(Player.Name)
I do not recommend you to access the player in this manner, because in some cases there could be names of objects that are the same as the Player's name in the Workspace.
Assuming that your script is a localscript, you can access the Character with simply:
game.Players.LocalPlayer.Character
Therefore, the best way to access the character model is this:
Human = Player.Character
Since a variable takes the place of something else, you do not need to write the whole name of the player model.
Also, I'd refer the player's mouse with a separate variable, so it would look cleaner.
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
Mouse.KeyDown:connect(function(key)
if string.lower(key) == "r" then
local Human = Player.Character
Human:WaitForChild("Humanoid").Health = 0
end
end)
6 comments
.
its still not working, on a side note...i know now to do Player.Character to get from Players to workspace more efficiently, how can I script Character to player efficiently?
Using "game.Players:GetPlayerFromCharacter(InsertCharacterHere)"
If it's not working, then, in line 1, add an entry like so: "repeat wait() until game.Players.LocalPlayer"
Be sure that the code is a LocalScript, that "Disabled" is set to false, and that the script is in StarterGui.
Ohhh, I didn't have it in StaterGui, thank you so much for your help