Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

If player name = "Name" then script?

Asked by 4 years ago

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

Log in to vote
0
Answered by 4 years ago
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
0
for the first example, you can use table.find instead of running a loop oSyM8V3N 429 — 4y
0
Thanks for the knowledge! May god bless you. WINDOWS10XPRO 438 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

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)
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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!

Answer this question