I want functions to happen when i press a key some of the functions include respawning characters. So i need the mouse.Target but that only works on everything but me... I've tried the script below it works on everything but my own character.
plr = game.Players.LocalPlayer mouse = plr:GetMouse() mouse.KeyDown:connect(function(key) if key:lower()=="r"then mouse.Target:Destroy() end end)
ROBLOX has specifically made it impossible to target any part inside your own character, otherwise you'd get fun errors like launching a rocket at your own face sometimes.
To get around this, you have to code smarter.
I would weld an invisible, uncollideable brick to the character's body, large enough to completely cover them, without creating too many glitches in movement. This brick cannot be parented to the Character in question, so I suggest making it a local brick and then checking to see if it was the brick clicked. If so, kill the player, if not, move on to the rest of the code. You won't be able to just Destroy() the brick, as that won't kill the player.
Also, Destroy()ing the player won't kill them if it destroys the entire model.