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

How to make a weapons barrel move when player shoots?

Asked by
WoTrox 345 Moderation Voter
4 years ago

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?

0
Try using Model:TranslateBy() instead of a for loop cailir 284 — 4y

1 answer

Log in to vote
1
Answered by
cegberry 432 Moderation Voter
4 years ago

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

0
^^^ and make sure the tweens can be overridden so that the player won’t experience broken recoils SmartNode 383 — 4y
0
Thank you!! WoTrox 345 — 4y
Ad

Answer this question