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

If player name = "Name" then script?

Hey so sort of new in scripting in roblox and me and my friends are working on a roblox game. But what i need is "If the player name is "DONTGIMMEUSELESS" then it runs the script. What this is is that i want a script only usable by admins (aka admin only script). Ex. I want to make an admin-only serverside executor and only admins can use it. (Not just that but maybe more.) Please help me if you can.

3 answers

✓ Accepted answer
local usernames = {"DONTGIMMEUSELESS", "putotherusernamehereifyouwant"}

game.Players.PlayerAdded:Connect(function(player)
	for i,v in pairs(usernames) do
		if player.Name == v then
			--script here
		end
	end
end)

if you don't want to add more usernames then do this

local Username = "DONTGIMMEUSELESS"

game.Players.PlayerAdded:Connect(function(player)
	if player.Name == Username then
		--script here
	end
end

2 comments

0

for the first example, you can use table.find instead of running a loop

0

Thanks for the knowledge! May god bless you.

This is simple, but I would recommend you to learn scripting by tutorials on YouTube.

local name = "DONTGIMMEUSELESS"

game.Players.PlayerAdded:Connect(function(player)
	if player.Name == name then
		-- enter your code here
	end
end)

Hello

I hear'd thats you need help with player name, Try This Script:

local TargetUser = game.Workspace:FindFirstChild("DONTGIMMEUSELESS")

game.Players.PlayerAdded:Connect(function()
       if TargetUser then
             print("The Target is Founded") -- You can change this Code
       end
end)

I hope it helped you!

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