Hi! I recently made an animation for my game but it seems that it doesn’t play?
This is the animation I made, it’s supposed to play if the player has pressed the R key
It works fine in the Animation Editor menu, but in-game it doesn’t work
I was pressing the R key but it won’t play the animation
local function Reload(Key)
if Key.KeyCode == Enum.KeyCode.R then
clicks = 17
ReloadAnimationTrack:Play()
ShootAnimationTrack:Stop()
script.Parent.Reloading:FireServer()
wait(2)
clicks = 0
print("Reloading..")
end
end
This is the code for the reloading function, the ReloadAnimationTrack is for the reload animation, it should play, I have put the right ID for the animations but it doesn’t work. Maybe someone can help me!
wait()
local CurrentCamera = workspace.CurrentCamera
local function Transparency(frame, transparency)
local TweenService = game:GetService("TweenService")
TweenService:Create(frame, TweenInfo.new(0.5), {ImageTransparency = transparency}):Play()
for _, v in pairs(frame:GetDescendants()) do
if v:IsA("GuiObject") then
if v:IsA("TextLabel") then
TweenService:Create(v, TweenInfo.new(0.8), {TextTransparency = transparency}):Play()
else
TweenService:Create(v, TweenInfo.new(0.8), {ImageTransparency = transparency}):Play()
end
end
end
end
local function ChangeFOV(camera ,fovvalue)
local TweenService = game:GetService("TweenService")
TweenService:Create(camera, TweenInfo.new(0.5), {FieldOfView = fovvalue}):Play()
end
local function ChangeSpeed(humanoid ,walkspeed)
local TweenService = game:GetService("TweenService")
TweenService:Create(humanoid, TweenInfo.new(0.5), {WalkSpeed = walkspeed}):Play()
end
local ViewModel = game.Workspace.Camera.Glock18VM
local player = game.Players.LocalPlayer
local mouse = game.Players.LocalPlayer:GetMouse()
local clicks = script.Parent.Shoots.Value
local Humanoid = game.Players.LocalPlayer.Character.Humanoid
local runService = game:GetService("RunService")
local camera = workspace.CurrentCamera
local function Recoil(amount, fade)
-- connect to the heartbeat function
local connection = nil
connection = runService.Heartbeat:Connect(function(deltaTime)
-- move the camera by amount
camera.CFrame *= CFrame.Angles(amount, 0, 0)
-- reduce amount
amount -= fade * deltaTime
-- if amount is still more then 0 exit the function and wait for next heartbeat
if amount > 0 then return end
-- amount is now less or equal to 0 so lets disconnect this function
connection:Disconnect()
end)
end
local IdleAnim = ViewModel.Idle
local ScopeAnim = ViewModel.Scope
local ShootAnim = ViewModel.Shoot
local ReloadAnim = ViewModel.Reload
local animController = ViewModel.AnimationController
local animator = animController.Animator
local IdleAnimationTrack = animator:LoadAnimation(IdleAnim)
local ScopeAnimationTrack = animator:LoadAnimation(ScopeAnim)
local ShootAnimationTrack = animator:LoadAnimation(ShootAnim)
local ReloadAnimationTrack = animator:LoadAnimation(ReloadAnim)
IdleAnimationTrack:Play()
local function Reload(Key)
if Key.KeyCode == Enum.KeyCode.R then
clicks = 17
ReloadAnimationTrack:Play()
ShootAnimationTrack:Stop()
script.Parent.Reloading:FireServer()
wait(2)
clicks = 0
print("Reloading..")
end
end
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local RPM = 500
local LastFired = tick()
local RecoilNum = 0.016
local function fire()
if (tick() - LastFired) < (1 /(RPM / 60)) then
return
end
clicks +=1
if clicks >=16 then
script.NoAmmo:Play()
ViewModel.Glock.End.Attachment.Flash.Enabled = false
else
ShootAnimationTrack:Play()
script.Parent.OnFire:FireServer(mouse.Hit.Position, workspace.CurrentCamera.CFrame)
Recoil(RecoilNum, 0.2)
ViewModel.Glock.End.Attachment.Flash.Enabled = true
end
LastFired = tick()
end
local FIRE_KEY = Enum.UserInputType.MouseButton1
local SPRINT_KEY = Enum.KeyCode.LeftShift
RunService.RenderStepped:Connect(function()
if UserInputService:IsMouseButtonPressed(FIRE_KEY) then
fire()
if clicks >=16 then
ViewModel.Glock.End.Attachment.Flash.Enabled = false
else
end
else
script.Parent.NotFiring:FireServer(mouse.Hit.Position, workspace.CurrentCamera.CFrame)
ViewModel.Glock.End.Attachment.Flash.Enabled = false
end
end)
RunService.RenderStepped:Connect(function()
if UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton2) then
ScopeAnimationTrack:Play()
player.PlayerGui.Cursor.FakeCursor.Visible = false
RecoilNum = 0.009
else
ScopeAnimationTrack:Stop()
RecoilNum = 0.016
player.PlayerGui.Cursor.FakeCursor.Visible = true
end
end)
game:GetService("UserInputService").InputBegan:Connect(Reload)
I made animationControllers inside the viewmodel (i stole some piece of code lol)
I feel like it’s a bug, because I’m happening to have a similar problem that my animation isn’t working at all upon trying it ingame, though it works in the animation editor. I do the same steps as usual to make the custom body rig and the modeling and etc. yet somehow I upload it to group or to me the animation and use the script I always use for the animation and somehow it doesn’t work, but other ones I made in the past work as it does always. crystal - Roblox < model with all stuff done to it, yet not working
“Core” is the weakest animation. You need to save and publish it as “Action.” Make sure the owner of the animation and the owner of the game are the same.
Make sure you are using R15 animations with R15 rigs.
Also, for testing purposes, turn on looped, comment out the stop commands, and see if the animation runs on the server.
Bit of a long-shot question, but just to confirm that the welds aren’t restricting any movement in game? The animation could be trying to play but the parts are just stuck.