I am making a script and I ran into an issue where my animation plays incorrectly. Here’s how it should look like and how it looks at the moment.
My animations are playing with priority action4.
local RunService:RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local PlayAnimationEvent = ReplicatedStorage:WaitForChild("Events"):WaitForChild("viewmodel-play_animation")
local StabEvent = ReplicatedStorage:WaitForChild("Events"):WaitForChild("knife-stab")
local KeybindModule = require(ReplicatedStorage:WaitForChild("Modules"):WaitForChild("Keybind"))
local Stab = KeybindModule.GetAction("stab","Stab")
Stab.KeyboardBinding.KeyCode = Enum.KeyCode.MouseLeftButton
Stab.GamepadBinding.KeyCode = Enum.KeyCode.ButtonR2
KeybindModule.EnableContext("stab")
local player_camera:Camera = workspace.CurrentCamera
local viewmodel = workspace:WaitForChild("Viewmodel")
local viewmodel_configuration = {
lerpSpeed = 0.3
}
local viewmodel_humanoid:Humanoid = viewmodel:WaitForChild("Humanoid")
local animator:Animator = viewmodel_humanoid:FindFirstChildWhichIsA("Animator") or viewmodel_humanoid:WaitForChild("Animator")
local function load_animation(id:string)
local animation = Instance.new("Animation")
animation.AnimationId = id
return animator:LoadAnimation(animation)
end
local stab_first = load_animation("rbxassetid://99972158053891")
local stab_second = load_animation("rbxassetid://75447958713488")
local overview = load_animation("rbxassetid://128262592824673")
stab_first.Priority = Enum.AnimationPriority.Action4
stab_second.Priority = Enum.AnimationPriority.Action2
overview.Priority = Enum.AnimationPriority.Action2
PlayAnimationEvent.OnClientEvent:Connect(function(Animation)
if Animation == "stab_first" then
stab_first:Play()
elseif Animation == "stab_second" then
--stab_second:Play()
stab_first:Play()
elseif Animation == "overview" then
overview:Play()
end
end)
Stab.Pressed:Connect(function()
print("pressed")
StabEvent:FireServer()
end)
viewmodel.Parent = player_camera
RunService.RenderStepped:Connect(function(deltaTime)
viewmodel:PivotTo(player_camera.CFrame)
end)