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

is there any good explanation of :GetPlayerFromCharacter() ?

Asked by 4 years ago

i dont realy understand it

1 answer

Log in to vote
0
Answered by
Joshument 110
4 years ago

The function :GetPlayerFromCharacter() will take the character model and give you the player corresponding to that. For example, let's say a player touched my part, and I want to display a message on their screen, I could use the function :GetPlayerFromCharacter() to get the player model, like so:

script.Parent.Touched:Connect(function(hit)
    local character = hit.Parent
    local player = workspace:GetPlayerFromCharacter(character)
    if player then
        --code
    end
end)
Ad

Answer this question