How to know if the player is the player that i want

So lets say i want owner perms how will i make a certain player have the owner abilities??

Game.Players.PlayerAdded:Connect(function(plr)
       if plr.UserId == YOUR_USER_ID_HERE then
        --Code
       end
end)
1 Like

Get the Player.UserId and compare it with all of the players in the server until one of them matches it.

You shouldn’t had gave the code to them.

can exploiters change their userid to my id so they can access the abilities?

It is 100% impossible. They can never will.

1 Like

Since this only focuses on the magnitude of a single player, you’re going to use a simple code that works like this:

local OWNER_USER_ID = 0 -- set ID here

game:GetService("Players").PlayerAdded:Connect(function(player)
    if player.UserId == OWNER_USER_ID then
        -- granting owner privileges
    end
end)

Alternatively, we have this:

game:GetService("Players").PlayerAdded:Connect(function(player)
    if game.CreatorType == Enum.CreatorType.User then -- CAUTION: This code works only on user-owned game, not group-based ones
        if player.UserId == game.CreatorId then
            -- privileges here
        end
    end
end)
1 Like

pretend i gave the solution to u also

pretend i gave the solution to u since u did answer what i wanted :blush:

They actually CAN change thier id client sided, But it wont work on server scripts.

1 Like

so other players cant see them do those abilities?
Lets say i have a race whoever comes 1st wins 25 gold coins
the exploiter uses my abilities from changing their id and change their walkspeed to 100 or smth
the exploiter comes 1st
will other players see him come 1st ???

No, but make sure to check the players’ IDs from the server.

1 Like

Depends on how you will script that, if you will script all the abilities on serverside they wont be able to use it.

1 Like

UserId(s) are not spoofable as far as I’m concerned. The only smoke screen that creates the belief that people could spoof it is poor (game) security.

1 Like

Exploiters can change thier walkspeed and jumppower, since player is NetworkOwner of thier character. Its pretty hard to avoid exploiters modifying thier humanoid. The only way to detect it is local script, that can get disabled by exploiter easily.

1 Like

soooo exploiters only have permission to use local scripts??
if i use remoteevent will they be able to revert the script to local script?

I cant really understand what do you mean by that but, exploiters have control over remote events, they can see incoming and outgoing info in order to use that in thier scripts. Just make sure to always check if player owns something or player is able to do something.

1 Like

Just to expand on your second code snippet.

local players = game:GetService("Players")
local groups = game:GetService("GroupService")
local getGroupsAsync = groups.GetGroupsAsync

players.PlayerAdded:Connect(function(player)
	if game.CreatorType == Enum.CreatorType.User then
		if player.UserId == game.CreatorId then
			--Player owns the game.
		end
	elseif game.CreatorType == Enum.CreatorType.Group then
		local success, result = pcall(getGroupsAsync, groups, player.UserId)
		if success then
			if result then
				for _, groupItem in ipairs(result) do
					if groupItem.Id == game.CreatorId then
						if groupItem.Rank == 255 then
							--Player owns the group which owns the game.
						end
					end
				end
			end
		else
			warn(result)
		end
	end
end)
local players = game:GetService("Players")
local groups = game:GetService("GroupService")
local getGroupInfoAsync = groups.GetGroupInfoAsync

players.PlayerAdded:Connect(function(player)
	if game.CreatorType == Enum.CreatorType.User then
		if player.UserId == game.CreatorId then
			--Player owns the game.
		end
	elseif game.CreatorType == Enum.CreatorType.Group then
		local success, result = pcall(getGroupInfoAsync, groups, game.CreatorId)
		if success then
			if result then
				if player.UserId == result.Owner.Id then
					--Player owns the group which owns the game.
				end
			end
		else
			warn(result)
		end
	end
end)
1 Like