How to make the GUI Close and open when E is clicked (If player's ID Is up there)
✓ ANSWER ACCEPTED
How to make the GUI Close and open when E is clicked (If player's ID Is up there)?
2 answers
✓ Accepted answer
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)
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 ?
This discussion is preserved as it was. New answers, comments, and votes are closed.

4 comments
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..
I am soo bad that I can't even make this work :
with just clicking a Brick and no Admin checks
This is because you can't use localscripts inside workspace, They need to be in starterplayerscripts or startercharacterscripts.