KeyboardEnabled Problem

        if not shopInfo:FindFirstChild("PCOnly") then
            print("PCOnly Disabled")
            game.ServerStorage.ShopTools:FindFirstChild(toolName):Clone().Parent = player.Backpack
        else
            print("PCOnly Enabled")
            if game:GetService("UserInputService").KeyboardEnabled == true then
                print("Keyboard Enabled")
                game.ServerStorage.ShopTools:FindFirstChild(toolName):Clone().Parent = player.Backpack
            else
                print("Keyboard Disabled")
                game.ServerStorage.DeviceGuns:FindFirstChild(toolName):Clone().Parent = player.Backpack
            end
     end

can someone tell my why this prints print("Keyboard Disabled") even if I have only keyboard turned on?

It looks like this is a server script. UserInputService only works correctly clientside. Even if it worked serverside, there can be multiple players in a game – the server script has no way to know which player you’re trying to get the input information for, so if you thought it through even without reading the documentation, this code doesn’t make sense.

It’s unclear why you’re changing which tool you’re giving to the player based on their input devices, but you should just make your tools work with all input devices so you don’t have to resort to hacks like this.

4 Likes

To add on to the above post, I can kind of get a sense for what you’re trying to do. Try looking into ContextActionService to make your tools work on any device, as well as UserInputService. This way, you only need one tool. You generally should be scripting once and accounting for all devices rather than trying to rely on what device type someone has.

1 Like