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

Why doesn't this helicopter control script work for console users?

Asked by 5 years ago
Edited 5 years ago

This script works for PC users and mobile users, however it doesn't work for console users. I know the script is pretty crude, but up until now, it worked pretty well. Output didn't give me anything.

Can someone help me?

Here's the code, with the problem area isolated from the rest:

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

function TouchTap(touch, gameProcessedEvent, mouse)
    rem.onMouseMoved:FireServer(mouse.Hit)
end


function onSelect(mouse)
    myMouse = mouse
    mouse.Icon = "http://www.roblox.com/asset/?id=8599980"
    if UserInputService.TouchEnabled then
        UserInputService.TouchTap:Connect(TouchTap, mouse)
        --mouse.Idle:connect(function() rem.onIdle:FireServer() end)
        --mouse.Button1Down:connect(function() rem.onMouseMoved:FireServer(mouse.Hit) end)
        gui = script.Parent.Functions:Clone()
        gui.Parent = player.PlayerGui
        for a,b in pairs(gui.frame:GetChildren()) do
            if b.ClassName == ("ImageButton") then 
                b.MouseButton1Click:connect(function() 
                    if b.Name == "start" then
                        rem.onKeyDown:FireServer("y")
                        b.Name = "stop"
                        b.TextLabel.Text = "Stop"
                    elseif b.Name == "stop" then
                        rem.onKeyDown:FireServer("x")
                        b.Name = "start"
                        b.TextLabel.Text = "Start"
                    elseif b.Name == "shoot1" then
                        --rem.onButton1Down:FireServer()
                        rem.onKeyDown:FireServer("f")
                    elseif b.Name == "shoot2" then
                        --rem.onButton1Down:FireServer()
                        rem.onKeyDown:FireServer("g")
                        wait()  
                        rem.onButton1Up:FireServer()
                    elseif b.Name == "scoot" then
                        rem.onKeyDown:FireServer("d")
                        b.Name = "stay"
                        b.TextLabel.Text = "Hover"
                    elseif b.Name == "stay" then
                        rem.onKeyDown:FireServer("a")
                        b.Name = "scoot"
                        b.TextLabel.Text = "Move"
                    elseif b.Name == "speed" then
                        rem.onKeyDown:FireServer("w")   
                    elseif b.Name == "slow" then
                        rem.onKeyDown:FireServer("s")           
                    end
                end)
            end 
        end
    elseif UserInputService.GamepadEnabled then 
--------------------------------- start of problem area
        UserInputService.InputBegan:connect(function(input, processed)
            if input.UserInputType == Enum.UserInputType.Gamepad1 then
                -- Check left thumbstick and move character on change
                if input.KeyCode == Enum.KeyCode.ButtonR2 then
                    rem.onKeyDown:FireServer("f")
                end
                -- Check right thumbstick and change camera angle on change
                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 of problem area
    else
        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)
    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)

while wait() do
    if (myMouse) then
        -- Position of mouse in world
        mousePoint = myMouse.Hit.p;
        if UserInputService.GamepadEnabled then
            rem.onMouseMoved:FireServer(myMouse.Hit)
            rem.onIdle:FireServer()
        end

    end
end

Answer this question