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

I have been gone a long time, and FE is confusing me again?

Asked by
IcyEvil 260 Moderation Voter
5 years ago

I have this in a server script

game.Workspace.Remote.GiveAdmin.OnServerEvent:connect()
game.Players.PlayerAdded:connect(function(plr)
local admins = {"azurael21", "Doxino", "IcyEvil", "EmperorVolvax"}
for _,v in pairs(admins) do
    if v == plr.Name then
    x = game.ServerStorage.Bunny:Clone()
    x.Parent = plr.PlayerGui
            end
        end
    end)

and this in a local script

game.Workspace.Remote.GiveAdmin:FireServer()

I can't seem to remember how to script with FilteringEnabled, but I know I should at least be on the right track. Any and all help is appreciated.

0
why do you have a PlayerAdded event inside the OnServerEvent ? this will create a new PlayerAdded event each time. User#5423 17 — 5y
0
It won't work anyways, OP didn't Connect OnServerEvent to any function. User#19524 175 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago

You are on the right track, the only problem is you didn't Connect OnServerEvent to a function. You won't be needing it anyways. You will need OnClientEvent to edit the PlayerGui.

--Server script

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local giveAdmin = ReplicatedStorage:WaitForChild("GiveAdmin")
local admins = {
    [41538450] = true,
    [game.CreatorId] = true
-- Insert the UserId of your admins here. [userid] = true
}

game:GetService("Players").PlayerAdded:Connect(function(plr)
    if admins[plr.UserId] then
        giveAdmin:FireClient(plr)
    end
end)

Client code:

-- LocalScript, under StarterGui

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local gui = ReplicatedStorage:WaitForChild("AdminGui")
-- Put it in ReplicatedStorage, putting it in server storage makes it inaccessible by client.

local giveAdmin = ReplicatedStorage:WaitForChild("GiveAdmin")
local player = Players.LocalPlayer 
local PlayerGui = player:WaitForChild("PlayerGui")

giveAdmin.OnClientEvent:Connect(function()
    gui:Clone().Parent = PlayerGui
end)

Hope this helped.

0
This most definitely does help, but it doesn't work, it says that I only have permission level 2, and it needs permission level 3? IcyEvil 260 — 5y
0
What line? User#19524 175 — 5y
0
It wasn't saying it was a line, it said it in developer console. Thats all, it just didn't work. IcyEvil 260 — 5y
Ad

Answer this question