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

How to Get a Character From a Player()?

Asked by
manith513 121
4 years ago

Hello guys so I am sure a lot of you know the way GetPlayerFromCharacter() works its when you usually use an event that triggers the player's body in workspace and gets their player form in the players category I want to do the opposite I want to get the character from player and I don't really know how to do that here is my script so far

game.Players.PlayerAdded:Connect(function(player)
    local bob = player:GetCharacterFromPlayer()

    local it = Instance.new("Part",bob.HumanoidRootPart)
end)
0
player.Character is the character you want Leamir 3138 — 4y

3 answers

Log in to vote
1
Answered by
Nckripted 580 Moderation Voter
4 years ago

Get the character like this:

local char = workspace:FindFirstChild(player.Name)

Hope this helped.

0
This can lead to erros, lets say that a player called "Part" joins, it may select any part called "Part" on his workspace Leamir 3138 — 4y
0
mmmm that would be true but the thing is that is impossible right as a roblox user needs to be a certain length? manith513 121 — 4y
0
I looked it up and there is indeed a person named part but that user hasn't been online since 2 years soooo manith513 121 — 4y
0
You could use tostring and prevent that from happening. Nckripted 580 — 4y
View all comments (2 more)
0
You could use tostring and prevent that from happening. Nckripted 580 — 4y
0
You could use tostring and prevent that from happening. Nckripted 580 — 4y
Ad
Log in to vote
1
Answered by
Benbebop 1049 Moderation Voter
4 years ago
Edited 4 years ago

In the future please add punctuation so we can understand faster and diagnose the problem with more accuracy.

Anyway here you go, its player.Character

Here is how it works.

game.Players.PlayerAdded:Connect(function(player)
    local bob = player.Character

    local it = Instance.new("Part",bob.HumanoidRootPart)
end)

Its simply an attribute that links directly to the Character.

0
ah thank you I didn't see this I should have accepted your answer as it is much clearer manith513 121 — 4y
Log in to vote
0
Answered by 4 years ago

You can do this through remote events, which in my opinion is a lot easier. Here's a video on remote events. https://www.youtube.com/watch?v=rsDpGP8VaGY

0
not sure how he would use remote events in this situation. What are you suggesting he does with them? Benbebop 1049 — 4y

Answer this question