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

Shop Opening By Clicking Key?

local player = game.Players.LocalPlayer
local Mouse = player:GetMouse()
local GUI = script.Parent.MainGUI
Mouse.KeyDown:connect(function(key)
	if key == "f" and GUI.Visible == false then
		GUI.Visible = true
	elseif key == "f" and GUI.Visible == true then
		GUI.Visible = false
end
  end)

For some reason, ROBLOX only recognizes LocalPlayer, and Player1 (The Test For Roblox Studio) what should I use to replace LocalPlayer, so that everyone can open the shop?

1 comment

0

Put it into a codeblock by clicking the Lua icon, then putting the code in between the squiggly lines. Simply edit your answer underneath your player on the right side.

1 answer

✓ Accepted answer
local player = game.Players.LocalPlayer
local Mouse = player:GetMouse() 
local GUI = script.Parent.MainGUI.Frame

Mouse.KeyDown:connect(function(key)
	if key == "f" then 
		GUI.Visible = not GUI.Visible
	end 
end)

You were calling on the GUI, not the frame inside. The GUI object is to hold the GUI elements. If everything is messy in the GUI then just put it in a frame that fits the whole screen.

1 comment

0

no, MainGUI is the name of the frame

This discussion is preserved as it was. New answers, comments, and votes are closed.