Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you get a Player's Character?

Asked by
Yeevivor4 155
8 years ago

Hello, thank you for reading. What I'm trying to do is that when a player enters a server, his health will be equaled to 0, causing him to be respawned. The thing is that I want to find the Humanoid but I can't do it. If anyone can help me, I'll be really happy.

Player = game.Players
function Character(character, Humanoid)
    if Player.Character ~= nil then
        print(Player.Character)
        Player.Character:findFirstChild("Humanoid")
        if Humanoid~= nil then
            Humanoid.Health = 0
        end
    end
end

1 answer

Log in to vote
0
Answered by 8 years ago

Solution

This solution has not been tested

You'd most likely want to use LoadCharacter() in this case, it's a better method to respawn the character. You also don't need to wait for the character to repsawn after the player dies. (if you were to try to set the 'Health' to 0)

It should be just right, but then again..

game.Players.PlayerAdded:connect(function(player)
    repeat wait() until player.Character;
                player:LoadCharacter();
                end;
    end);

If this worked then put it as the answer, if it didn't then tell me if there is a problem

0
I think you misunderstood the question but he's not asking how to load the character he's asking how to get the player's character. User#5978 25 — 8y
0
Yeah.. His goal was for the Character to respawn, but his true question was finding the players Character.  Vezious 310 — 8y
Ad

Answer this question