Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

4 comments

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..

0

I am soo bad that I can't even make this work :

0

with just clicking a Brick and no Admin checks

0

This is because you can't use localscripts inside workspace, They need to be in starterplayerscripts or startercharacterscripts.

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.