GetPlayerFromCharacter returning nil value

Hi, I don’t know why is this happening, but when doing game.Palyers:GetPlayerFromCharacter(actualkiller) (Players variable is game.Players) it returns nil. I checked the actual killer variable by printing it, and it prints the player value. https://gyazo.com/8c1ae3cefb7cf8ec2120281e51eea2f4

any idea on what could be going on? like if the variable contains the name of the player, why does it return nil?

-- i forgot to add a players variable
local players = game:GetService('Players') -- if you change the name of players, it wont affect
local player = players:GetPlayerFromCharacter(workspace:WaitForChild('FartMaster69'))
if (not player) then return print('the rig is just a normal rig') end
print(('%s is a memer'):format(player.Name))

Make sure you are defining Players correctly.

local Players = game:GetService("Players")

game:GetService(“Players”) doesn’t seems to be the problem.

doing the workspace thing will still get me the player from Players right? not the player object from workspace

Could it be that actualkiller is the Player instance? Print out the ClassName of actualkiller, if it returns Player, then you already have the player instance

It prints Model https://gyazo.com/384fcb7f5abf17b1b03986d75ec6efbb

so like it’s getting the name of the player from the workshop, and then should find the player with that name in the Players folder

What did you use for the print? print(actualkiller.ClassName)? If so, odd. Maybe you may need to use FindFirstChild using the name of the thing in the value instead of GetPlayerFromCharacter?

Players:FindFirstChild(killername)

maybe lemme check and see if it works hehe

1 Like

oke, I mark this as a solution cuz I found the problem thanks to printing classnames. it was getting the playername from workshop, not frommPlayers folder. I now know how to do it. again thx!

1 Like

Glad that my reply has helped you reached a conclusion! If you have anymore issues don’t be afraid to make another post!

1 Like