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

Whats wrong with this Starterpack Script?

Asked by
iLegitus 130
10 years ago
-- iLegimate --

Player = script.Parent.Parent


function ifPlayerAdmin()
    if Player.Name == "iLegimate" or "Paulyus1" or "Rrog" or "coolmist52" or "concord44" then
        x = game.ReplicatedStorage.ADMINGatesOpener:Clone()
        x.Parent = Player.PlayerGui
    end
end 


ifPlayerAdmin()

Surprisingly its giving the GUI to just anyone,Not those people only (The ones in "") Howcome? And can anyone help me debug it?

0
The Parent.PlayerGui seems to be wrong. change player variable to Player = game.players.localplayer and out the script in localscript in startgui NinjoOnline 1146 — 10y
0
Still doesnt work..? iLegitus 130 — 10y
0
I have added a full answer. Try that then come back if it dosen't work again. NinjoOnline 1146 — 10y

3 answers

Log in to vote
1
Answered by 10 years ago

Try this in a LocalScript inside of StarterGui. The code you've supplied is quite inefficient and can be made easier.

admins = {"YourName", "SomeOtherName", "AnotherName"} --Insert people's names in here as strings, separating each one with a comma like the example shows
local player = game.Players.LocalPlayer

function isAdmin(name)
    for i = 1, #admins do
        if admins[i]:lower() == name:lower() then
            return true
        end
    end
    return false
end

player.CharacterAdded:connect(function(char)
    if isAdmin(player.Name) then
        x = game.ReplicatedStorage.ADMINGatesOpener:Clone()
        x.Parent = player.PlayerGui
    end
end)            
Ad
Log in to vote
0
Answered by 10 years ago
-- iLegimate --

LocalPlayers = game.Players.LocalPlayer

while true do
    game.Players.PlayerAdded:connect(function(player)
        if player.Name == "iLegimate" or player.Name "Paulyus1" or player.Name "Rrog" or player.Name "coolmist52" or player.Name "concord44" then
            x = game.ReplicatedStorage.ADMINGatesOpener:Clone()
            x.Parent = LocalPlayers.PlayerGui
            end
    end)
    wait(1)
end

Put this is a LocalScript and put that inside StarterGui The reason I believe it wasn't working was one, needs to be inside LocalScript to access the LocalPlayer, secondly, the answer above is right, it need to have Player.Name or Player.Name, etc and three, the Player variable has to be changed to Players with an s or the** Player.Name** check won't work. Hope I have helped.

If that above dosent work then try this one too

-- iLegimate --

LocalPlayers = game.Players.LocalPlayer

while true do
    game.Players.PlayerAdded:connect(function(player)
        if player.Name == "iLegimate" or player.Name == "Paulyus1" or player.Name == "Rrog" or player.Name == "coolmist52" or player.Name == "concord44" then
            x = game.ReplicatedStorage.ADMINGatesOpener:Clone()
            x.Parent = LocalPlayers.PlayerGui
            end
    end)
    wait(1)
end
0
If this dosent work then change one thing NinjoOnline 1146 — 10y
0
The one below is more efficient So I would accept that one, but make sure to thumbs up this one too. NinjoOnline 1146 — 10y
Log in to vote
-2
Answered by 10 years ago
-- iLegimate --

Player = script.Parent.Parent


function ifPlayerAdmin()
    if Player.Name == "iLegimate" or Player.Name == "Paulyus1" or Player.Name == "Rrog" or Player.Name == "coolmist52" or Player.Name == "concord44" then
        x = game.ReplicatedStorage.ADMINGatesOpener:Clone()
        x.Parent = Player.PlayerGui
    end
end 


ifPlayerAdmin()

0
You still have to type Player.Name after or. SilenceCore 25 — 10y

Answer this question