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.
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