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

How to make a weapons barrel move when player shoots?

I have the script, the Mouse.Button1Down is fine. I want to make it like when the player shoots the barrel goes back then forward. I have a Barrel, a BarrelRecoil (where should the barrel go) and a BarrelRecoilBack (the barrels original position) inside the weapon. I tried to use...

Barrel.Position = BarrelRecoil.Position

wait(0.2)

Barrel.Position = BarrelRecoilBack.Position

...but that has a weird - laggy looking. I also tried...

local fnsh = BarrelRecoil.CFrame
local strt = BarrelRecoilBack.CFrame

for process = 0, 101, 15 do
	
	Barrel.CFrame = strt:Lerp(fnsh, process)
	wait()

end

...this didnt work too (No error code). What should I use?

1 comment

0

Try using Model:TranslateBy() instead of a for loop

1 answer

✓ Accepted answer

You can use TweenService:Create and TweenInfo.new to create smooth animation effects

2 comments

0

^^^ and make sure the tweens can be overridden so that the player won’t experience broken recoils

0

Thank you!!

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