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

Player is a nil value?

My script is like this:

script.Parent.Shoot.OnServerEvent:Connect(function(PlrName,MouseyPos)
	print(MouseyPos)
		local Char = script.Parent
	local PlrInThisWeapon = game:GetService("Players"):GetChildren(Char.Name)
---------etc.

Why it got player's name, but can't find player? Help me!

2 comments

0

no

0

btw its not sending the name of the player it is sending the player itself as an object

1 answer

✓ Accepted answer

you have to follow the script, GetChildren does not get one object, it gets all the children, and Players object does not have GetChildren function.

I just use the following script

local player
for _,p in pairs(game.Players:GetPlayers()) do
	if p.Name == playerName then 
		player = p 
		break 
	end
end

1 comment

0

You CAN use GetChildren on Players service though.

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