Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to get player from character that is not controlled by player?

Getting player from character that is controlled by player has a built in function

game.Players:playerFromCharacter(character)

does getting player from character that is not controlled by player have one too?

2 comments

0

idk but you can make your own get player from charcter function

1

:playerFromCharacter is not a method. GetPlayerFromCharacter is

1 answer

✓ Accepted answer

here's a function you can make:

local function playerFromCharacter(char)
	local player=game.Players[char.Name]
	return player
end

3 comments

0

I tried using game.Players:FindFirstChild(character.Name) (didnt work still nil). What difference did it have with game.Players[character.Name]? (Works)

0

i am not sure if i'm being honest with you, i started using [] these brackets more often and my scripts became more efficient

0

can you tell me the difference between () and []? Sounds like I could use it too xD

This discussion is preserved as it was. New answers, comments, and votes are closed.