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

How would I create my first weapon module?

Asked by 7 years ago
Edited 7 years ago

So basically what I'm trying to say is that I am trying to further advance my level of scripting by learning how to create weapon modules (scripts). I kind of get the jist on how CFrame works, but I'm trying to learn how to use it in a powerful way. For example, would I use CFrame.lerp to create a smooth reloading animation? Or would I use CloneTrooper1019's Model Rigging Plugin and make an animation of it using the Roblox Animation Editor? I know this sounds kind of confusing, but my problem is I need the basics on how to do it. Hopefully this makes sense. Thank you in advance.

0
why does everyone use an animation creator plugin? hiimgoodpack 2009 — 7y
0
@himgoodpack it's because it is an easy way to make animations @PyccknnXakep it depends - both work fine. My personal preference is using animations because they are quick and easy to use - I can't be bothered with the math and trial-and-error required for CFrame animations. You may want to look into TweenService on the note of CFrame animations, also. TheDeadlyPanther 2460 — 7y

1 answer

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

I can't really say much on the topic of CFrame animations, but I'll show you how to do Roblox animations (my personal preference).

local AnimationObject = script:WaitForChild("Animation")
-->> The Animation object is required to use LoadAnimation
-->> This object would have a property called AnimationId that you use to load the animation

local AnimationTrack = Humanoid:LoadAnimation(AnimationObject)
-->> LoadAnimation returns an AnimationTrack that has some properties (e.g, PlaybackSpeed)
-->> It's also what 'loads' the animation
-->> Looping is a property of an AnimationTrack, but it is read only because it is part of the asset (use the plugin to change it)
-->> It also Play and Stop

AnimationTrack:Play()

That's the basics of using an animation. Animating works (and replicates) on both the client and the server.

To put this into the context of a gun module:

local ReloadId = 0000

local ReloadAnimationObject  = Instance.new("Animation",script)
ReloadAnimationObject.AnimationId = "rbxassetid://" ..ReloadId
ReloadAnimationObject.Name = "Reload"
local ReloadAnimation = Humanoid:LoadAnimation(ReloadAnimationObject)

function Module.Reload()
    ReloadAnimation:Play()
    ReloadAnimation.Ended:Wait() -->> Don't have wiki access right now, but I think this is the right event
end

Hope I helped!

~TDP

Ad

Answer this question