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

What is wrong with this script? [SOLVED]

 local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

 local open = false

mouse.KeyDown:connect(function(key)
	if key == "q" then
		if open == false then
			open = true
				script.Parent.ShopFrame.Visible = true
		elseif open == true then
			open = false
				script.Parent.ShopFrame.Visible = false
		end
	end
end

I have tried to fix it but i cant find out what is wrong

1 answer

✓ Accepted answer

You forgot the end parenthesis at the end on line 4

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

local open = false

mouse.KeyDown:connect(function(key) --The open parenthesis before the "function" needs to be closed
    if key == "q" then
        if open == false then
            open = true
                script.Parent.ShopFrame.Visible = true
        elseif open == true then
            open = false
                script.Parent.ShopFrame.Visible = false
        end
    end
end) --There was no parenthesis here

Like my answer if you found it useful!

6 comments

0

oh, Thanks!

0

is there any way that i could make the mouse able to move while it is open (My game is locked in first person)

0

I'm pretty sure you can just right click while your mouse is over the GUI, and it will unlock the mouse

0

If you're stuck in first person, and your mouse won't move, then press ESC

0

i cant move my mouse onto the GUI, it is at the side of the screen

0

but i can just move the gui to the middle

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