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

Tool based console-compatibility localscript not working at all. Why?

Asked by 5 years ago
Edited 5 years ago

This script is supposed to register commands inputted by a console user, and then interpret them as PC commands. I did the same method for mobile and it worked (using GUIs), but for console it doesn't work at all.

I used messages to show what parts worked, and "activated xbox2" showed, but it wouldn't show what keys were entered, meaning that keys weren't recognized. Output gave me nothing to work with, as I had to use my Xbox One to test.

Could someone help me with this? Here's the script.

local seat=script.Parent.Fake
local rem=seat.Value.ServerToolStuff.Remotes
local player = game.Players.LocalPlayer
local gui
local UserInputService = game:GetService("UserInputService")
local new = Instance.new("Message", game.Workspace)
myMouse = nil

function onSelect(mouse)
    myMouse = mouse
    mouse.Icon = "http://www.roblox.com/asset/?id=8599980"
    if UserInputService.GamepadEnabled then 
        new.Text = "activated xbox3"
        UserInputService.InputEnded:Connect(function(input, processed)
            new.Text = "activated xbox1"
            if input.UserInputType == Enum.UserInputType.Gamepad1 then
                new.Text = "activated xbox2"
                new.Text = "yeah "..input.KeyCode
                if input.KeyCode == Enum.KeyCode.ButtonR2 then
                    rem.onKeyDown:FireServer("f")
                end
                if input.KeyCode == Enum.KeyCode.ButtonL2 then
                    rem.onKeyDown:FireServer("g")
                end
                if input.KeyCode == Enum.KeyCode.ButtonY then
                    rem.onKeyDown:FireServer("y")
                end
                if input.KeyCode == Enum.KeyCode.ButtonX then
                    rem.onKeyDown:FireServer("x")
                end
                if input.KeyCode == Enum.KeyCode.ButtonB then
                    rem.onKeyDown:FireServer("d")
                end
                if input.KeyCode == Enum.KeyCode.ButtonL3 then
                    rem.onKeyDown:FireServer("a")
                end
                if input.KeyCode == Enum.KeyCode.DPadUp then
                    rem.onKeyDown:FireServer("w")
                end
                if input.KeyCode == Enum.KeyCode.DPadDown then
                    rem.onKeyDown:FireServer("s")
                end
            end
        end)    
    end
    mouse.Button1Down:connect(function() rem.onButton1Down:FireServer() end)
    mouse.Button1Up:connect(function() rem.onButton1Up:FireServer() end)
    mouse.Move:connect(function() rem.onMouseMoved:FireServer(mouse.Hit) end)                mouse.Idle:connect(function() rem.onIdle:FireServer() end)
    mouse.KeyDown:connect(function(key) rem.onKeyDown:FireServer(key) end)
    mouse.KeyUp:connect(function(key) rem.onButton1Up:FireServer() end)
end

function ondeSelect(mouse)
    myMouse = nil
    if gui ~= nil then
        gui:Destroy()
    end
end

script.Parent.Selected:Connect(onSelect)
script.Parent.Deselected:Connect(ondeSelect)

Answer this question