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

How to make the GUI Close and open when E is clicked (If player's ID Is up there)?

Asked by 2 years ago

How to make the GUI Close and open when E is clicked (If player's ID Is up there)

2 answers

Log in to vote
0
Answered by
Neatwyy 123
2 years ago
Edited 2 years ago

My my I'm confused with your code, but hopefully I'm able to help you! First of all, you can't use player:GetMouse() on the server. Second of all, you should make a localscript and a serverscript but I'm gonna make it simple and only make it on the client. Lastly, you should use UserInputService instead of player:GetMouse().

Here's the code!

-- LocalScript

local plr = game.Players.LocalPlayer
local adminIDs = {1224124949}
local uis = game:GetService("UserInputService")

uis.InputBegan:Connect(function(input, isTyping)
    if isTyping then
        return
    end

    if not table.find(adminIDs, plr.UserId) then
        return
    end

    if input.KeyCode == Enum.KeyCode.E then
        plr.PlayerGui.AdminGui.Enabled = not plr.PlayerGui.AdminGui.Enabled
    end
end)
0
Well, I am new so that's why my code is Sh*t XD anyway... the code you sent didn't work not sure why. i made a localScript in workspace and added the code but nope.. Hamoodiyt 26 — 2y
0
I am soo bad that I can't even make this work : Hamoodiyt 26 — 2y
0
with just clicking a Brick and no Admin checks Hamoodiyt 26 — 2y
0
This is because you can't use localscripts inside workspace, They need to be in starterplayerscripts or startercharacterscripts. kegirosou 17 — 2y
Ad
Log in to vote
0
Answered by 2 years ago
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local clicked = true
game.ReplicatedStorage.AdminClicked.OnServerEvent:Connect(function(admin, plrChosen)
local adminIDs = {1224124949}


game.Players.PlayerAdded:Connect(function(plr)

    if table.find(adminIDs, plr.UserId) then
mouse.KeyDown:connect(function(key)
    if key:lower() == "e" or key:upper() == "E" then
        if clicked == true then
        clicked = false
        plrChosen:WaitForChild("PlayerGui").AdminGui.Enabeld = false
        else return end

    end
end)

    if table.find(adminIDs, plr.UserId) then
        mouse.KeyDown:connect(function(key)
            if key:lower() == "e" or key:upper() == "E" then
                if clicked == false then
                clicked = true
                plrChosen:WaitForChild("PlayerGui").AdminGui.Enabeld = true
            else return end


    end
end)

This one didn't work any 1 know why ?

Answer this question