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

How would I create my first weapon module?

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.

2 comments

0

why does everyone use an animation creator plugin?

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.

1 answer

✓ Accepted answer

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

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