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

How do you set an animation to a hotkey? or a command?

Asked by 8 years ago

Got no idea... how but i know its possible... i think...

2 answers

Log in to vote
1
Answered by
Vexture 179
8 years ago

I think these wiki articles should be helpful to you!

This article will teach you how to create and play an animation: http://wiki.roblox.com/index.php?title=Animations

This article teaches you about the UserInputService (for your hotkey setting): http://wiki.roblox.com/index.php?title=API:Class/UserInputService

I hope this helps you!

Ad
Log in to vote
0
Answered by 8 years ago

For all scripts concerning and using the keyboard, the mouse variable needs to be applied always.

mouse = game.Players.LocalPlayer:GetMouse()

Due to the variable referring to LocalPlayer as LocalPlayer is only accessed from local scripts, the script has to be a local script. I cannot assume what you mean by hotkey but I will assume it is your toolbar. The toolbar numbers are 1, 2, 3, 4, 5, 6, 7, 8, 9, 0. However, players cannot press any other numbers then the toolbar numbers, so this makes the statement of executing this line of code easier as you only need to know if the key pressed is a number. Also, local scripts are supported by filtering.

If you use a non-handled tool or tool, either way, this is the simply best two functions in the starting of the script inside of it, this is hotkey based when the tool is equipped.

tool = script.Parent
mouse = game.Players.LocalPlayer:GetMouse()
tool.Equipped:connect(function()
    mouse.KeyDown:connect(function(key)
        if (tonumber(key)) then
            local character = game.Players.LocalPlayer.Character -- refers to the character
            --else scripts goes here, such as running the animation. the character variable is useful if your gonna make a script of code animating the player if you want
        end
    end)
end) 

A no-tool script, it is a local script and works without tool equip.

mouse = game.Players.LocalPlayer:GetMouse()
mouse.KeyDown:connect(function(key)
    if (tonumber(key)) then
        --else scripts goes here, such as running the animation and etc
    end
end)

A verbal command using the ROBLOX's default chat, it is not case-sensitive and is a regular script:

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        message = msg:lower()
        if message == "run animation" or message == ":runanimation" or message == ":animation" or message == "animation run" or message == "animate" then
            --else scripts will go here, such as running the animations, other scripts of code, and etc.
        end
    end)
end)

Refer to these articles for more information about animations and info to help you with your needs:

Creating and playing animations (Using the animation plugin and etc) - http://wiki.roblox.com/index.php?title=Animations

UserInputService (shows functions, properties, and events) - http://wiki.roblox.com/index.php?title=API:Class/UserInputService

If you want to animate a character's body part without a plugin or animation ID being runned, using youtube is a good source. All the properties that will be needed for this effectively is C0, C1, Part1, Part0. These are also properties for welds, which are used more commonly for parts then character limbs.

0
I think Friaza has a good source for character animating without a plugin or animation ID, rather as in a script, find him on youtube. AshRPG12 42 — 8y

Answer this question