How to tween a slide on a gun tool?

is it not possible with a script?

it is but id say do animations bro. using scripts is unneeded and not really the best thing.

loading animations is much easier then tweening or cframing stuff.

Well you could do a motor 6d animation that plays every time you fire the tool. I Reconmend to learn motor 6d animations.

I want to use cframes because I have tons of guns and going in and animating the slide on each one is harder than just a script.

like i said its easier animating the weapons instead of cframing a welded part…

So… If anyone still want to know i did by adding to my gun Model a “slide Start” part and a “slide End”
And i tween the slide motor6d between those two parts. since this parts are already motor6d’d to the gun i dont have to worry about the slider drifting around.
The code looks like this:


function module.ReciprocateGun(gun:Model,gunData:WeaponsDataShared.Gun)
	local gunReciprocatorMotor :Motor6D = gun:FindFirstChild('ReciprocatorMotor6D',true)
	local reciprocatorStartMotor:Motor6D = gun:FindFirstChild('ReciprocatorStartMotor6D',true)
	local reciprocatorEndMotor:Motor6D = gun:FindFirstChild('ReciprocatorEndMotor6D',true)
	
	if gunReciprocatorMotor and reciprocatorEndMotor and reciprocatorStartMotor then
		print('reciprocate')
		local startGoal = {
			C0 = reciprocatorEndMotor.C0
		}
		local endGoal = {
			C0 = reciprocatorStartMotor.C0
		}
		local info = TweenInfo.new((0.08 / 2) , Enum.EasingStyle.Quad, Enum.EasingDirection.In)
		local tweenStart:Tween = TweenService:Create(gunReciprocatorMotor, info, startGoal)
		local tweenEnd:Tween = TweenService:Create(gunReciprocatorMotor, info, endGoal)
		tweenStart:Play()
		tweenStart.Completed:Connect(function()
			tweenEnd:Play()
		end)
	end
	
end

Quick note:
I weld my parts at run time with a custom welding function and i did this because i am doing a procedural FPS framework for my game and sice i am a one man team i cannot afford the time to animate guns.

Screenshot 2024-03-30 at 11.25.38 PM

1 Like