Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why do my animations never work, but animations work for other people?

Here's my code:

local _M = require(script.Parent.Settings)
local tool = script.Parent

repeat wait() until game.Players:GetPlayerFromCharacter(tool.Parent)
local plr = game.Players:GetPlayerFromCharacter(tool.Parent)
local db = false

tool.Activated:Connect(function()
	if not db then
		db = true
		plr.leaderstats.Magic.Value = plr.leaderstats.Magic.Value + _M.mpc
		local anim = game.ReplicatedStorage:FindFirstChild("CastWand")
		local animtrack = plr.Character.Humanoid:LoadAnimation(anim)
		animtrack:Play()
		wait(_M.cooldown)
		db = false
	end
end)

I'm making a simulator (original right?), and I'm trying to make it so when I click with my wand it casts a spell. There are no errors in f9 but no animations are loaded when I click. My animation is https://www.roblox.com/library/5357129951/Cast-Wand if you're wondering. Any help? Thanks. (edit: if u wanna test it urself https://www.roblox.com/games/5030437155/aha?refPageId=709f453d-4cd0-408b-96d1-9892da0ba6b0)

5 comments

0

Is your animation's prority Action, because if not, that might be why it doesn't work.

0

Yes.

0

Ok then, I'll Look into it

0

Fixed it.

0

ill post the answer anyway, i literally just got it

1 answer

✓ Accepted answer

Your proble was u didnt set your priority to Action, my code fixed that, note that i used an animation id not an animation locally

local plr = game.Players.LocalPlayer -- Local Player
local chr = plr.Character or plr.CharacterAdded:Wait() -- Gets Character
local hum = chr:WaitForChild("Humanoid") -- Waits for player's humanoid to load in
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://5357268177" -- Replace this ID with yours
local Animation = hum:LoadAnimation(animation) 
Animation.Priority = Enum.AnimationPriority.Action
local db = false -- Debounce so no spam clicking
script.Parent.Activated:Connect(function()
	if plr and chr and hum then
		if not db then
			db = true
			Animation:Play() -- Plays Animation
			wait(1)
			db = false
		end
	end
end)

It shoudl work now

2 comments

0

Although I fixed it before hand this would've worked since it wasn't action even though I had set it to it before hand so for attempting to help, have fun with the rep.

0

ye thx a lot

This discussion is preserved as it was. New answers, comments, and votes are closed.