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

So I need a script where when I press a key in a car seat it triggers a animation?

Asked by 3 years ago

Does anyone know how to make a script where when someone is sitting in a car seat and they press a key of my choosing it triggers a animation.

1 answer

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

Insert a Localscript in StarterGui and paste the following:

local AnimationID = "          " --The ID of the animation you want to play
local UIS = Game:GetService("UserInputService") -- The input service
local Player = game.Players.Local
local Character = Player.Character or Player.CharacterAdded:Wait()

local Anim = Instance.new("Animation") -- Creates an Animation
Anim.AnimationId = AnimationID -- Sets the AnimationID

local Main = Character:WaitForChild("Humanoid"):LoadAnimation(Anim) --Loads

UIS.InputBegan:Connect(function(input) -- When an Input starts
    if input.UserInputType = Enum.UserInputType.Keyboard then

        if input.KeyCode == Enum.KeyCode.E then--Change key to what you like
            Main:Play() -- Plays the previously loaded animation
        end

    end
end)
Ad

Answer this question