Local Animation not firing

Trying to get this animation to fire on the client, but it is refusing to do. It is weird cause I have another script that fires perfectly fine, but this one doesn’t.

Here is the script not firing the animation. The function itself works, because it does fire the event, just no animations play with it.

local userinputserv = game:GetService("UserInputService")
local event = game.ReplicatedStorage:WaitForChild("SpellPart3")
local intevent = game.ReplicatedStorage:WaitForChild("InteractionEvent")
local db = game:GetService("Debris")
local tweenserv = game:GetService("TweenService")

local player = game.Players.LocalPlayer
local chara = player.Character or player.CharacterAdded:Wait()
local charaHum = chara:WaitForChild("Humanoid")
local animator = charaHum:WaitForChild("Animator")

local SingHit = Instance.new("Animation")
SingHit.AnimationId = "rbxassetid://13038848754"

local SingleHitTrack = animator:LoadAnimation(SingHit)
SingleHitTrack.Priority = Enum.AnimationPriority.Action
SingleHitTrack.Looped = false

local IntFold = chara:WaitForChild("Interactions")
local Hit = IntFold.HitInt

Hit.Changed:Connect (function()
	if Hit.Value == 1 or Hit.Value == 2 then
		local inQ = 1
		local ValueSent = Hit.Value
		intevent:FireServer(inQ, ValueSent)

		SingleHitTrack:Play()
		SingleHitTrack:AdjustSpeed(0.75)
	end
end)

And here is the script that works for reference;

local userinputserv = game:GetService("UserInputService")
local event = game.ReplicatedStorage:WaitForChild("SpellPart3")
local intevent = game.ReplicatedStorage:WaitForChild("InteractionEvent")
local db = game:GetService("Debris")
local tweenserv = game:GetService("TweenService")

local player = game.Players.LocalPlayer
local chara = player.Character or player.CharacterAdded:Wait()
local charaHum = chara:WaitForChild("Humanoid")
local animator = charaHum:WaitForChild("Animator")
local mouse = player:GetMouse()

local spell = script.Parent

local equipped = false
local debounce = false
local charging = false

local SlashAni = Instance.new("Animation")
SlashAni.AnimationId = "rbxassetid://12913730510"

local SlashAniTrack = animator:LoadAnimation(SlashAni)
SlashAniTrack.Priority = Enum.AnimationPriority.Action
SlashAniTrack.Looped = false

spell.Equipped:Connect(function()
	equipped = true
end)

spell.Unequipped:Connect(function()
	equipped = false
end)

userinputserv.InputBegan:Connect(function(input, gpe)
	if not equipped then return end
	if gpe then return end
	if input.UserInputType == Enum.UserInputType.MouseButton1 and not debounce then
		local spellcode = "1Basic"
		
		local InQ = 5
		local Value = 1
		
		event:FireServer(nil, spellcode)
		intevent:FireServer(InQ, Value, ManaCost)
		
		SlashAniTrack:Play()
		SlashAniTrack:AdjustSpeed(0.75)
		debounce = true

		task.wait(3)
		debounce = false
	end
end)

Both scripts are also in startercharacterscripts. The priority for both are action as well and I made the animations myself so not a permission issue.

what is ManaCost?

intevent:FireServer(InQ, Value, ManaCost)

Value defined before the function, there is like 10 others but I cut them out to just what I am trying to fix

What is IntFold.HitInt (Hit)??

IntValue created in another script that changes to 1 when a character in game is hit, it works because that event inside the changed function fires, just the animation doesnt play

I’ve tried everything I can possibly find on the Studio, anyone got any ideas?

Can you run the affected script in each side: Client And Server?

I originally had the animations played server side, but ran into more problems. After checking the animation api, I figured that client would be for the best, but just not working.

By run, do you just mean switch it over to a server script (change up the variables obvi) or?

It’s more fixable to run to each side because there are people resolving with this.

I recommend that you start your script again at least you may be able to solve your problem.

Alright, I’ll give it a try in about a hour

Load the animation into the Humanoid, not animator. Or at least that’s how it’s typically done.

It played the animations, but they are glitching and not stopping. I also made sure that their priority is set right, but they keep just looping even with the variable set false. Should I put I script it for both client and server?

This ended up working, the second glitch I encountered had to do with something else. Thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.