How do I get the local player in a serverscript?

Thankyou but what would i use t ge the player id? I dont know how to get it

Player instance.UserId should work. I’m assuming you have a player object where you fire the bullet. If not maybe the character object

I just noticed the UserId is an integer, so use an intvalue. Then when you obtain the UserId from the bullet, use:

local player = game.Players:GetPlayerbyUserId(bullet.Owner.Value)

no no no how do i get the player id in the firstplace

I answered that above. From the script where you create the bullet or fire the bullet, you must have a player instance or character instance at that point. And its just player.UserId. If you have the character then use:
game.Players:GetPlayerFromCharacter(character)

1 Like

Im trying to get player id like this:

	local Playerid = MyPlayer.UserId
	BulletClone.Owner.Value = Playerid

My player is got by:

	local creatorTag = Instance.new('ObjectValue', Bullet)
	creatorTag.Value = MyPlayer
	creatorTag.Name = 'creator'

And it is saying the error GetPlayerbyUserId is not a valid member of Players “Players” for this line

local player = game.Players:GetPlayerbyUserId(Bullet.Owner.Value)

I’m sorry the “b” should be capitalized in By

‘’’game.Players:GetPlayerByUserId()’’’

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.