Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.