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

How can I make a script usable by a specific person?

Asked by 7 years ago

I am making a game that has powers and such, and I made a custom power. I don't want other people to use my custom power, so how do I make it so that I can only use it?

3 answers

Log in to vote
0
Answered by
gitrog 326 Moderation Voter
7 years ago

I personally prefer this method as it is much simpler.

01local hasPower = {
02        ["gitrog"] = true,
03        ["spartanlord456"] = true --add as many names as you need
04    }
05 
06game.Players.PlayerAdded:connect(function(player)
07    player.CharacterAdded:connect(function(character)
08        if hasPower[player.Name] then
09            --power script here
10        end
11    end)
12end)
Ad
Log in to vote
4
Answered by 7 years ago

You can use game.Players.PlayerAdded:Connect(function() to check if the player is a certain player.

Add a Server Script into **ServerScriptService** and then type in this code;

01game.Players.PlayerAdded:Connect(function(plr) -- fires when player join the game
02 
03    local PlayerRole = Instance.new('Folder') -- Holds the roles
04    PlayerRole.Parent = plr
05    PlayerRole.Name = 'PlayerRole'
06    wait() -- wait's for player to load in
07    local AdminRole = Instance.new('BoolValue') -- a bool value
08    AdminRole.Parent = PlayerRole -- goes inside player
09    AdminRole.Name = 'AdminRole'
10    AdminRole.Value = false -- no admin
11 
12    if plr.Name == "Your username" then
13        AdminRole.Value = true
14    end
15end)

and then in your script that gives superpowers just do something like this;

1if AdminRole.Value == true then
2    -- gives player power
3end

This is an easy way.

Log in to vote
-1
Answered by
IcyEvil 260 Moderation Voter
7 years ago

You can always check a players name.

When I am trying to check to see if there is a certain player in the game I like to use this method.

01local p = {'PlayerName', 'player'} -- remove the {'s and the extra "player" then it will be a singular person
02game.Players.PlayerAdded:connect(function(plr)
03if plr.Name = p then
04 
05 
06-- code here
07 
08 
09end
10end)

But of course, Its not very efficient, plenty of methods that are better then that such as.

1game.Players.PlayerAdded:connect(function(plr)
2if plr.Name == 'PlayerName'then
3 
4-- code here
5 
6end
7end)

But I prefer my way, :)

Anyways hope this helps.

0
line 3 Goulstem 8144 — 7y
0
I know it's been over a year, but I forgot to accept your answer. I'll be doing that right now. Sorry! spartanlord456 19 — 6y

Answer this question