Ad
Log in to vote
0

How to make inputs while in a seat?

Asked by 3 days ago

Im trying to make a keyboard input to make the vehicle do an action but everything I tried from tutorials do not work.

The script is a Local scripts and I have tried it as a normal. I understand Locals are used to detect player input.

The script is attached to the seat itself.

--Truck Parts
local seat = script.Parent
local truck = seat.Parent
local craneExtended = false

--Crane Parts
local CraneDrive = truck.TruckBase.CraneDrive
local ForeCraneDrive = truck.Crane.CraneUpperArm.ForeCraneDrive

--Input
local UserInputService = game:GetService("UserInputService")

local function operateCrane(actionName, userInputState, inputObject)
    if userInputState == Enum.UserInputState.Begin then
        print("R was pressed")
        if craneExtended == false then
            CraneDrive.TargetAngle = -110
            ForeCraneDrive.TargetAngle = -70
            craneExtended = true
        else        
            CraneDrive.TargetAngle = 0
            ForeCraneDrive.TargetAngle = 0
            craneExtended = false
        end
    end
end 

game.ContextActionService:BindAction("keyPress", operateCrane, false, Enum.KeyCode.R)
0
use :GetService() to get CAS EXpodo1234ALT 684 — 3d
0
thats context action service theking48989987 456 — 3d
0
Can someone expand please and give an example? Gamezdude 0 — 3d

Answer this question