Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesn't this script work? please help

Asked by 10 years ago

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

Log in to vote
-1
Answered by 10 years ago

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)
0
the local Mouse is suppose to be on line 2 but its just making it weird :l tyronecruz12345 0 — 10y
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. TheeDeathCaster 2368 — 10y
0
Whoops. Forgot to move the mouse. MrLonely1221 701 — 10y
Ad

Answer this question