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

Why doesn't this script work? please help

I need help on this script i tried everything and can't find the problem, I'm trying to make it were you click "G" and a frame will pop up like a backpack gui please help and thanks

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

Mouse.KeyDown:connect(function(Key)
    if Key:lower() == "g" then
        if script.Parent.MainFrame.Visible == false then -- if the location's visible property is true then 
            script.Parent.MainFrame.Visible = true -- DO this
        else -- Otherwise, 
            script.Parent.MainFrame.Visible = false -- Do this
        end
        -- That's all 
    end
end)

1 answer

Your problem was the script was on one line and not getting through. I fixed this for you and it should work now.

local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse()

Mouse.KeyDown:connect(function(Key)
	if Key:lower() == "g" then
		if game.StarterGui["Grief Backpack gui"].MainFrame.Visible == false then -- if the location's visible property is true then 
			game.StarterGui["Grief Backpack gui"].MainFrame.Visible = true -- DO this
		else -- Otherwise, 
			game.StarterGui["Grief Backpack gui"].MainFrame.Visible = false -- Do this
		end
		-- That's all 
	end
end)

3 comments

0

the local Mouse is suppose to be on line 2 but its just making it weird :l

0

This code will not work because: 1. You are having the code set the GUIs Visibility in STARTERGUI to true, not the ACTUAL Player's PLAYERGUI. 2. PlayerGui displays/replicates a GUI, StarterGui only Clones the GUIs/Children into the Player's PlayerGui, but your code is changing the Visibility in 'StarterGui', not the PlayerGui, thus, this code will not work until the Player resets multiple times.

0

Whoops. Forgot to move the mouse.

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