How to make gun animation in roblox studio
How to make gun animation in roblox studio
How To Make a Gun on Roblox
Gun Tutorial code download
Download the full script for this gun tutorial below.
Here’s what your game should look like:
Side notes
–Make sure that your game is set up like mine, with all objects added in – Make sure FilteringEnabled is turned on – Make sure that you make your own animations and set your animation IDs to your IDs as you cannot currently take someone else’s animations!
–Main Script which goes in Server Storage.
replicatedStorage.EquipAnimation.OnServerEvent:Connect( function (player,animation)
local newAnim = game.Workspace[player.Name].Humanoid:LoadAnimation(animation)
newAnim:Play()
replicatedStorage.UnequipAnimation.OnServerEvent:Connect( function (player,animation)
newAnim:Stop()
for i,v in pairs (game.Workspace:GetChildren()) do
if v.Name == player.Name.. “‘s Trajectory” then
v:Destroy()
end
end
end )
replicatedStorage.Reload.OnServerEvent:Connect( function (player,animation)
newAnim:Stop()
local reloadAnim = game.Workspace[player.Name].Humanoid:LoadAnimation(animation)
reloadAnim:Play()
end )
end )
function checkBodyType (player,tool)
if game.Workspace[player.Name]:FindFirstChild( “LowerTorso” ) then — R15
tool.shoot.AnimationId = “rbxassetid://936531673”
tool.reload.AnimationId = “rbxassetid://937806099”
return “R15”
end
if game.Workspace[player.Name]:FindFirstChild( “Torso” ) then — R6
tool.shoot.AnimationId = “rbxassetid://1000874313”
tool.reload.AnimationId = “rbxassetid://937933712”
return “R6”
end
end
replicatedStorage.CheckBodyType.OnServerInvoke = checkBodyType
— Local Script, which goes inside the tool
— Leaderboard code which goes inside ServerScriptService, optional to include, you can add your own if you want but bear in mind the gun won’t work unless you have some sort of leaderboard with a Kills and Wipeouts stat
— Data saving code goes here if you need it
end )
This was a lengthy tutorial from me, my longest yet! If you want to watch more tutorials on how to script on Roblox, remember to subscribe to my channel.
Using the Animation Editor
Roblox Studio features a powerful, built-in Animation Editor which allows you to design and publish custom animations.
Model Requirements
The animation editor can be used for both stock human characters or non-human models, as long as all moving parts are connected with Motor6D objects. Assuming your model is compatible, follow these steps to begin creating an animation:
Using Default Rigs
If you’re new to Roblox animation, it’s recommended that you start with one of the default rigs created through the Build Rig button in the Plugins tab. These rigs already contain the basic parts and mechanisms to build a character animation.
Creating Poses
To animate a rig, you’ll need to define poses by moving/rotating specific parts like the head, right hand, left foot, etc. When the animation runs, it will smoothly animate the rig from pose to pose.
Consider a simple animation where a human character turns its head 45° to the left. This animation involves two poses — the initial position of the head (looking forward) and the turned position of the head (looking left).
To create a new pose:
Adjusting the Timeline Duration
By default, the timeline displays a duration of 1 second (30 frames), although the animation’s actual duration will be determined by the final keyframe. To add more time to the timeline view, enter a new value in the right-side box of the position indicator:
Working With Keyframes
Once you define basic poses for a rig, fine-tuning individual keyframes can significantly improve the final animation.
Adding Keyframes
As shown in the poses section above, keyframes are automatically added when you change a part’s orientation anywhere along the timeline. In addition, keyframes can be added as follows:
Moving Keyframes
To increase or decrease the amount of time between a keyframe and a neighboring keyframe:
Copying Keyframes
A specific keyframe (or keyframes for multiple parts) can be copied and pasted to a new position in the timeline.
Deleting Keyframes
Animation Easing
Easing is an important concept in animation. By default, a part will move/rotate from one keyframe to the next in an even, steady motion known as linear easing.
As you can see, linear easing makes the character’s kick animation appear stiff and robotic. While that may look appropriate for some motions, compare the following video where cubic easing is applied to make the leg animate more naturally.
To change easing for one or more keyframes:
Easing Style | Description |
---|---|
Linear | Moves at a constant speed. |
Constant | Removes interpolation between the selected keyframe and next keyframe (animation will «snap» from keyframe to keyframe). |
Cubic | Eases in or out with cubic interpolation. |
Elastic | Moves as if the object is attached to a rubber band. |
Bounce | Moves as if the start or end position of the tween is bouncy. |
Easing Direction | Description |
---|---|
Out | The motion will be faster at the beginning and slower toward the end. |
InOut | In and Out on the same tween, with In at the beginning and Out taking effect halfway through. |
In | The motion will be slower at the beginning and faster toward the end. |
Inverse Kinematics
When animating characters, inverse kinematics (IK) can help calculate rotations for neighboring joints in order to get one specific joint to a desired location.
To begin editing an animation in IK mode:
IK Modes
IK features both Body Part mode (exclusive to /articles/r6 vs r15 avatars|R15/Rthro rigs) and Full Body mode. This can be toggled from the IK window.
Body Part Mode | Full Body Mode |
---|---|
Isolates movement to related limbs. For example, moving the RightHand part will only affect parts that compose the right arm. | The IK solver will consider all joints when moving a specific part. However, you may exclude specific parts from this process by pinning them (see below). |
Pinning Parts
When editing an animation in Full Body mode, you can pin a part to make it immovable. In the following video, both feet are pinned and remain stationary while moving other parts, but either foot can still be directly manipulated.
To pin a specific part, click the pin icon next to its name. Remember that Full Body mode must be enabled to use this feature.
Exiting IK Mode
To return to “forward kinematics” mode, click on Disable IK near the bottom of the IK window. Note that this will not remove any manipulations you made while in IK mode — that data will remain stored in any keyframes which were created while IK was applied.
Animation Settings
Looping
When designing an animation in the editor, you can toggle on the Looping button to make it automatically loop:
Priority
In an actual game, you’ll probably use unique animations for different player actions and states, for instance a jump animation and an “idle” animation. Logically, the jump animation should take priority over the idle animation so that characters don’t perform both at the same time.
You can set one of four priority levels as follows:
Animation Events
Animation event markers can be defined across the timeline span and AnimationTrack/GetMarkerReachedSignal|GetMarkerReachedSignal() can be used to detect those markers as the animation runs.
Showing Events
By default, the event track isn’t visible. To reveal it:
Creating Events
To create a new event marker:
Detecting Events
Event Parameters
As noted earlier, you can specify a Parameter value for any event marker within the animation editor. This lets you pass a custom string (single value, comma-separated string, etc.) to the AnimationTrack/GetMarkerReachedSignal|GetMarkerReachedSignal() function as illustrated by the paramString argument in the code example above. This string can then be parsed or converted, if necessary, and used for whatever action you wish to perform in the event.
Cloning Events
As you create events, they become available for usage throughout the animation, not only at the time position where you created them. For instance, you can create a “FootStep” event marker at the point where a character’s left foot touches down, then use the same event when the character’s right foot touches down.
To clone an event:
Saving and Exporting
Once you’re satisfied with an animation, you can either save it as a KeyframeSequence object or export it to Roblox for use in your games.
Saving to Project
To save an animation as a KeyframeSequence :
Exporting to Roblox
To use an animation in an actual game, you must export it to Roblox and note the assigned asset ID.
Important Settings for Default Character Animations
How to make ANIMATED GUN SKINS in ROBLOX STUDIO 2021!
Показать панель управления
Комментарии • 104
Place to test this (NOT UNCOPYLOCKED) :
www.roblox.com/games/6782935649/Animated-Texture-tutorial
Hey, by the way, you can actually tween multiple properties in one tween. You could do:
local tween = TweenService:Create(texture, tweenInfo,
Just pointing it out, multiple Tweens could be messy, so this is a solution.
@polarisprog Happy to help!!
Thank you! I never knew about this!
Could you do a tutorial on how to make multiple gun skins that players can select for their default guns in the locker?
Thank you so much! I have trouble trying to find a tutorial using this method!
You earned yourself a sub, my dude!
You are amazing, i will definitely use your tutorials man, you earned a sub and likes.
Thanks so much bro! Im working on a fps game rn, making skins lol but this tutorial helped!!
Glad I could help!
Can you make a Tool Skin system which allows the player to switch skins between skins for their tool? If you can then this can be very cool.
Thanks! It works perfectly for my biggest game project! 😀
THANK YOU SO MUCH POLAR THIS HELPED A LOT 😀
Hello I am new to your channel and I love the simulator series, Can u show us how to make a gun with a reload animation, zoom in/out like a sniper pls?
OMG THANKS FINNALY A VIDEO THAT EXPLAINS HOW IT WORKS
I could not even script it myself
woah, i never thought u had this, thank u for this 😀
can you pls do eggs hatching system with the chances and the stats
you don’t have to create multiple tweens for this
I’m using this code: local tweenService = game:GetService(‘TweenService’)
local object = script.Parent
local TextureSpeed = 40
local tweenInfo = TweenInfo.new(
TextureSpeed,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out
-1,
false,
0
)
for _, texture in pairs(object:GetChildren()) do
if object:IsA(‘BasePart’) or object:IsA(‘UnionOperation’ ) then
for _, texture in pairs(object:GetChildren()) do
if texture:IsA(‘Texture’) then
local textureTween = tweenService:Create(texture, tweenInfo,
local textureTween2 = tweenService:Create(texture, tweenInfo,
textureTween2:Play()
end
end
end
end
and for some reason it doesn’t give the animation
Can you please make a tutorial on how to make a skin shop using this? I think it will be pretty sick thanks in advance
@Zai Sahay sadly he never made the video
@polarisprog Looking forward for the vid! Thank you!
Kích thước video:
Hiển thị các điều khiển trình phát
NHẬN XÉT • 316
I made a vid that is way better than this one after almost 2 years
here’s the link: vnclip.net/video/wbsMS2MGVTg/video.html
Thanks for the video, it was very helpful! I just wanted to ask if you knew how to change the players speed when they are holding the gun, such as if this gun model is a machine gun, then the player would move slower. Thanks again!
MyCookiesAreFresh thx I’ll try it
@C4_TotoHold shift and click button under the esacape button on the top left of ur keyboard
4:29 whats the thing after «model» in line 52
Oh for that you just add in Global script when equipped the tool’s parent object’s humanoid walkspeed is changed and when unequipped the same humanoid walkspeed is changed to what it was originally
Also welcome!
What does the beam do in the Object module? What if I want it to be raycast instead of projectiles?
Heyya, can you teach me more simple about how the gun works? Just the part where u make the bullets through client-side and server-side. You don’t really need to answer this though, im still a bit confused.
Because when i make the bullets with server-side and client-side, the shooter will see the 2 bullets created through those 2 environment
hey i know you i look at your video that how to make a costom character that help so much thank you
Thank you so much! This really helped because I have been wanting to make a gun on roblox for years!
This is exactly what i need in my game ty!
If ur stuck, just download the model put it in ur workspace and then make ur own gun and then transport everything in the model into ur gun
Hello, great tutorial.
How do I change the GUI/UI?
woah great tutorial! I’ll definitely use it for my game!
Hey this tutorial was great but for some reason not every player is being given the weapon do you know if this is fixable?
Great job this helps alot
The final product doesnt do damage to players for some reason
Thanks! It works but whenever I shoot it lags so much! 🙁
Thanks for the tutorial. However, there seems to be mini lag spikes when i fire the gun; is there a way to fix this? Thank you
I realized this is because you shot a model with like over 100+ parts so what you do is you exclude those models that have a lot of parts in the humanoid detection part of the script
very good but if the gun is a mesh it doesn’t work and when you shoot its very laggy.
Is there a way so the gun is the tool itself and not in a model?
I know this video is pretty old itself but is there a way where I can insert an animation? Such as shooting this certain weapon ( like a shotgun ) then the person pumps the gun to chamber the next shell.
It’s a very good tutorial but can you help me make a model that all players can see your bullets?
Great video, really helped me
though I do need some help as after Copy and Pasting the scripts into my own gun model, the bullets did not do any damage
do you know why?
Check to see if the global script is disabled. If it is, enable it
How do i change the gun damage so it doesn’t damage the players health quick
@Epiclightningswordx i fix that bug, but i do a scar i put in auto mode and shoot like a minigun, how i can fix that? I checked the bullet speed I set 1 and keep shooting like a minigun
Thx, and yeah the gun is not absolutely «perfect» cause while using it in my game I had to fix lots of bugs again
Make it so that the gun does not try to detect the sub-Objects (children) in a folder or model and also weld the other part to the handle when the tool is in workspace while editing
Do you know how to Change were the Ball comes from? Or the Bullets?
Quick question, how do you change the speed that each bullet is fired? More specifically, how do I make this fire like a normal gun and not a laser lol. Thanks a ton.
change the values of the bullet in the module script
How do you put a stop to Wall shooting and corner shooting? My temp solution was to make the muzzle point backwards in the handle, then disable the tracers
Ah alright thanks.
You can instead of placing the chamber attachment where the gun chamber is you would put it in front of the player’s face that way corner shooting would be stopped
Hey I want to know that when you reload the gun the max ammo decreases until the point you can no longer use it. Can I make the gun’s MaxAmmo does not decrease?
@Epiclightningswordx what is the name of the variable in objects that does not decrease the ammo?
I’m sorry to say, but the gun doesn’t work. When i shoot it fires hundreds of events, the bullets appear yes, but when you shoot the bullets only go down.
Can you show us how to make a sniper with this gun model and how to change the name without it disappearing?
Can you do animations and dual wield?
When I tested it, it said there was no BasGunFinal in ServerScriptService, any way to prevent this?
Only legends say the npc’s are still being shot
it helped me to create FPS game, i only change some parts and add ads system of it in order to make other weapons
Is it possible to add a reload animation to it
You got any way of implementing animations into this? Other than that this be pretty nice
thank
Where do you get FX building tools?
How do you make the gun have infinite bullets?
Hey Does It Count as permission to put this in a game? Making a custom one idk
Thanks, it really helped for my current project!
Hey I imported the model but I don’t know how to make it so the model won’t just be the brick can u tell me what to do?
awesome tutorial
took less time to make unlike alvin blox’s how to make a gun
super good quality
here you can copy the setup variables: local sss = script.parent
local guns = <
sss.BaseGunFinal,
>
is this working with models too?Im asking it before i finish so lets find out.
I have two questions
— Can you tell me how to make a pistol and not a SMG?
— I also want a shotgun
I try to config it but it still does it like a SMG help 🙁
Just increase the guns delayed and Lower the delay for SMGs and Pistols, And shotguns Increase the *SPREAD*
how do you refill ammo?
How to rig this to the hands so you see it perfectly on First-person?
When i put the gun with the gungiver and replicator in the gun and i put the gun to the severscriptservice it can shoot but it not cost the damage i dont know why please can u fix it 🙂
legend says that guy is still spinning and shooting his gun
How can i change fire rate and laser
?
Can you move the text becuz it gets in the way of the script
Thx this will work for my messing around game which is kinda like the matrix
Thanks it works
Fantastic tutorial, I got a question tho, can you make a quick video on how to put reload sounds, And how to put animations for reloading, idle and firing? And also how to put it in the workspace cuz It would be real good to be able to pick it up from the ground rather then it spawning in your inventory automatically. if you can make a tutorial like that it would me fantastic, and I’d truly think this would be the best way to make a gun, Also, forgot to mention that when I put multiple bullets, the sounds start to glitch out and the rays start to glitch too, But overall, fantastic gun, thank you for this tutorial.
@Epiclightningswordx Yeah, that seems nice, Also, another tip is making the trail able to glow as well, or maybe bullet impact effects, up to you tho, don’t wanna nitpick, but it would be nice to know how to make the gun do 1 sound cuz when I try to do it, it can start to lag, It would be cool to know how to make the gun have a limited clipsize without limited ammo, or maybe even a muzzle flash or chaningable gui fonts. Again, not trying to be nitpicky, I just have alot of faith in your work and I think you possibly have the best roblox gun scripting in your hands when even some of the best games don’t, and your tutorials are really helpful, k anyways, keep up the great work!
That’s a good idea, and I can combine it along with something else I’m doing related to the gun!
I tested with 300 bullets at once and that’s probably the lag when making multiple moving parts so it sounds like that too (if you want you can just do one sound instead of multiple at once to save performance)
How do you make it to be as team tool so it can work when i putitto the team and by commands give it it deals no damage
Как в roblox studio поставить анимацию на персонажа
As you create events, they become available for usage throughout the animation, not only at the time position where you created them. For instance, you can create a “FootStep” event marker at the point where a character’s left foot touches down, then use the same event when the character’s right foot touches down.
как сделать анимацию персонажа в роблокс студио
хех е бои. Скрипт: local seat = script.Parent function added(child) if (child.className «Weld») then local human = child.part1.
Привет, я — Влад. В этом гайде я расскажу о плагине «мун аниматор». Это гайд для начинающих аниматоров в роблоксе.
1 СКРИПТ: wait(3) Player = game.Players.LocalPlayer.Character animation1 = Player.Humanoid:LoadAnimation(script.
1 вариант. Создание НПС в Roblox с нуля
Для начала создадим с вами нашего NPC с нуля в базовом шаблоне Classic Baseplate. Выберем первый Part и с помощью инструмента Scale изменим его до нужной нам высоты. Далее выберем и изменим цвет, сдублируем наш блок и выведем копию рядом с первым блоком. Это у нас будут ноги нашего NPC. Добавим ещё один блок, отредактируем его с помощью инструментов Scale и Move и вставим данный Part посередине, чтобы временно визуально зафиксировать ноги нашего объекта, потом мы его обязательно удалим.
Следующим блоком сделаем туловище NPC, не забыв поменять его цвет. Инструменты Move и Scale нам в помощь. Следом станут левая и правая руки, добавим очередной Part, изменим с помощью Move и Scale, добавим другой цвет.
Добавим голову для нашего героя. Поскольку изначально такого блока для добавления не предусмотрено, добавим простой Part и перейдем в его настройки, нажав на знак плюс, и выберем опцию Special Mesh. После этого мы увидим, что наш блок стал круглым, как голова. Ставим голову на самый верх нашей конструкции и выделяем все созданные блоки. После чего нажимаем на кнопку «Группировать» (Group на панели Toolbar). После этого удалим наш ненужный блок между ног и переименуем персонажа, нажав на клавишу F2, а также поменяем названия всех Part на названия частей тела. После этого возвращаем курсор на имя героя, выделяем его, нажимаем правой клавишей мыши и выбираем Humanoid (нажатие по плюсику и выбор Humanoid). Как видим, наши блоки объединились в одну конструкцию, наш NPC стал полноценным объектом, к которому мы можем добавлять все, что пожелаем.
Выбираем нужный симулятор
Если вы хотите увидеть большее количество различных танцев от собственного персонажа, проще перейти на специально предназначенный для этого сервер. Наиболее популярный симулятор, максимально соответствующий данной теме, это Adopt
Me.
Как только вы зайдете на сервер, сделайте левый клик мышью на собственном персонаже и выберите одно из действий в появившемся меню. Это может быть:
Как видите, танцевать в Roblox очень просто. Осталось лишь приложить немного фантазии и удивить окружающих красивыми движениями персонажа.
Animation Settings and Events
In the Animation Editor, you’ll find a Looping button. It will allow you to loop specific animations. However, it won’t optimally blend the final keyframe with the first keyframe.
A workaround for this issue would be to copy your first keyframe and use it as the last one. If you do this, the looper will be able to interpolate between the two keyframes.
It’s also at this point where you’ll want to assign a priority for your animation. Priorities are listed as follows from lowest to highest.
Note that setting a higher priority will allow you to override a lower priority animation while it’s playing.
How to Reveal and Create Events
How to Save Animations
You save an animation as a KeyframeSequence. Here’s how to do it:
If you just save your animation and don’t export it, you won’t be able to use it outside the editor. And, you will need the asset ID to script the animation for use in games.
Inverse Kinematics
When animating characters, inverse kinematics (IK) can help calculate rotations for neighboring joints in order to get one specific joint to a desired location.
Uh oh! Your browser doesn’t appear to support embedded videos! Here is a direct link to the video instead.
To begin editing an animation in IK mode:
IK Modes
IK features both Body Part mode (exclusive to /articles/r6 vs r15 avatars|R15/Rthro rigs) and Full Body mode. This can be toggled from the IK window.
Body Part Mode | Full Body Mode |
---|---|
Isolates movement to related limbs. For example, moving the RightHand part will only affect parts that compose the right arm. | The IK solver will consider all joints when moving a specific part. However, you may exclude specific parts from this process by pinning them (see below). |
Pinning Parts
When editing an animation in Full Body mode, you can pin a part to make it immovable. In the following video, both feet are pinned and remain stationary while moving other parts, but either foot can still be directly manipulated.
Uh oh! Your browser doesn’t appear to support embedded videos! Here is a direct link to the video instead.
To pin a specific part, click the pin icon next to its name. Remember that Full Body mode must be enabled to use this feature.
Exiting IK Mode
To return to “forward kinematics” mode, click on Disable IK near the bottom of the IK window. Note that this will not remove any manipulations you made while in IK mode — that data will remain stored in any keyframes which were created while IK was applied.
Animation Settings
Looping
When designing an animation in the editor, you can toggle on the Looping button to make it automatically loop:
Priority
In an actual game, you’ll probably use unique animations for different player actions and states, for instance a jump animation and an “idle” animation. Logically, the jump animation should take priority over the idle animation so that characters don’t perform both at the same time.
You can set one of four priority levels as follows:
Источники информации:
- http://developer.roblox.com/en-us/articles/using-animation-editor
- http://clip-share.net/video/06YxrcPuOqM/how-to-make-animated-gun-skins-in-roblox-studio-2021.html
- http://vnclip.net/video/L9mj_KMODIA/roblox-studio-how-to-make-a-gun-in-roblox.html
- http://io-mope.ru/roblox/kak-v-roblox-studio-postavit-animaciju-na-personazha/