In my game I’m trying to make a realistic revolver animation. When the trigger is pulled, the hammer should go back, and then return really quickly to fire the round. And this indeed happens with my current script.
But if the gun isn’t lined up with the X axis (it’s rotated in the Y and or Z axis) then this happens.
The hammer still rotates 60 degrees in the X axis, but I need it to rotate BACK which happens to be in the X axis when it’s not rotated in the Y or Z axis (if you understand what I mean).
Here is my script:
local player = game.Players.LocalPlayer
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local TweenService = game:GetService("TweenService")
local hammer = character.Hammer
function Fire()
local OriginalRotation = hammer.Rotation
local tweenInfo = TweenInfo.new(0.4, Enum.EasingStyle.Cubic, Enum.EasingDirection.In)
local tween = TweenService:Create(hammer, tweenInfo, {Rotation = hammer.Rotation + Vector3.new(-60, 0, 0)})
tween:Play()
wait(0.5)
local tweenInfo1 = TweenInfo.new(0.0025, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out)
local tween1 = TweenService:Create(hammer, tweenInfo, {Rotation = hammer.Rotation - Vector3.new(-60, 0, 0)})
tween1:Play()
--wait(0.25)
tween1.Completed:Wait()
local animation = Instance.new("Animation")
animation.AnimationId = "http://www.roblox.com/asset/?id=16799062288"
local animationTrack = humanoid:LoadAnimation(animation)
animationTrack:Play()
end
wait(5)
Fire()
There is probably a simple solution for this but I’m all out of ideas. I appreciate any help I get though.