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

Trying to open a shop with a key pressed. Not working, and no errors however. tips?

Asked by 6 years ago
Edited 6 years ago
wait()
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()


ScreenGui =script.Parent.Parent
RobuxFrame = ScreenGui.RobuxFrame
MainFrame = ScreenGui.MainFrame
MedicineFrame = ScreenGui.MedicineFrame
ArmorFrame = ScreenGui.ArmorFrame
UpgradeFrame = ScreenGui.UpgradeFrame
WeaponFrame = ScreenGui.WeaponFrame

Medicine = ScreenGui.Medicine
Armor   = ScreenGui.Armor
Robux  = ScreenGui.Robux  
Weapons   = ScreenGui.Weapons
Upgrades = ScreenGui.Upgrades



RobuxFrame.Visible = false
MainFrame.Visible = false
MedicineFrame.Visible = false
ArmorFrame.Visible = false  
UpgradeFrame.Visible = false 
WeaponFrame.Visible = false 

Medicine.Visible = false 
Armor.Visible = false 
Robux.Visible = false  
Weapons.Visible = false   
Upgrades.Visible = false


function PressQ(key)
    if (key == "q") 

        RobuxFrame.Visible = false
        MainFrame.Visible = true
        MedicineFrame.Visible = false
        ArmorFrame.Visible = false  
        UpgradeFrame.Visible = false
        WeaponFrame.Visible = false

        Medicine.Visible = true 
        Armor.Visible = true 
        Robux.Visible = true  
        Weapons.Visible = true   
        Upgrades.Visible = true 

    end
end

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Hi there,

Your aim currently would be to get the player's key press. However, you seem to be using a function which doesn't have a trigger...Additionally, your current method is deprecated in favour of a new method of getting the player's key pressed. Here's the new method:

Using UserInputService, change your keypress function to this:

function onKeyPress(inputObject, gameProcessedEvent)
    if inputObject.KeyCode == Enum.KeyCode.Q then
         RobuxFrame.Visible = false
            MainFrame.Visible = true
            MedicineFrame.Visible = false
            ArmorFrame.Visible = false  
            UpgradeFrame.Visible = false
            WeaponFrame.Visible = false

            Medicine.Visible = true 
            Armor.Visible = true 
            Robux.Visible = true  
            Weapons.Visible = true   
            Upgrades.Visible = true 
    end
end

game:GetService("UserInputService").InputBegan:connect(onKeyPress)

If you would like more information on this new way of key pressing click the following link below. http://wiki.roblox.com/index.php?title=Keyboard_input

Also, here is the link to the deprecated method. Avoid this link if it confuses you. http://wiki.roblox.com/index.php?title=Keyboard_input_(deprecated)

Ad

Answer this question