How to make the GUI Close and open when E is clicked (If player's ID Is up there)
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 ?