Sword animation working in studio but not in roblox client

Hi Robloxians,
I have made a sword script and animation. It works completely fine in studio but animation doesn’t play in roblox player, what should I do?

Here is the script:

Tool = script.Parent
Handle = Tool:WaitForChild("Handle")
Debounce = true
Trail = script.Parent.Handle.SwordSlashTrail
SwordLight = script.Parent.Handle.SwordLight
HitBox = script.Parent.Handle.HitBox
HitBoxS = script.Parent.Handle.HitBox.DamageScript
EffectS = script.Parent.Handle.HitBox.Effects

function Create(ty)
	return function(data)
		local obj = Instance.new(ty)
		for k, v in pairs(data) do
			if type(k) == 'number' then
				v.Parent = obj
			else
				obj[k] = v
			end
		end
		return obj
	end
end

local BaseUrl = "rbxassetid://"

Players = game:GetService("Players")
Debris = game:GetService("Debris")
RunService = game:GetService("RunService")

DamageValues = {
	SlashDamage = 0,
}


SlashAnimations = {
	"rbxassetid://12905465996",
}

Grips = {
	Up = CFrame.new(0, 0, -1.70000005, 0, 0, 1, 1, 0, 0, 0, 1, 0),
	Out = CFrame.new(0, 0, -1.70000005, 0, 1, 0, 1, -0, 0, 0, 0, -1)
}

Sounds = {
	Slash = Handle:WaitForChild("SwordSlash"),
	Unsheath = Handle:WaitForChild("Unsheath")
}

ToolEquipped = false


Tool.Grip = Grips.Up
Tool.Enabled = true



function IsTeamMate(Player1, Player2)
	return (Player1 and Player2 and not Player1.Neutral and not Player2.Neutral and Player1.TeamColor == Player2.TeamColor)
end

function TagHumanoid(humanoid, player)
	local Creator_Tag = Instance.new("ObjectValue")
	Creator_Tag.Name = "creator"
	Creator_Tag.Value = player
	Debris:AddItem(Creator_Tag, 2)
	Creator_Tag.Parent = humanoid
end

function UntagHumanoid(humanoid)
	for i, v in pairs(humanoid:GetChildren()) do
		if v:IsA("ObjectValue") and v.Name == "creator" then
			v:Destroy()
		end
	end
end

function Blow(Hit)
	if not Hit or not Hit.Parent or not CheckIfAlive() or not ToolEquipped then
		return
	end
	local RightArm = Character:FindFirstChild("Right Arm") or Character:FindFirstChild("RightHand")
	if not RightArm then
		return
	end
	local RightGrip = RightArm:FindFirstChild("RightGrip")
	if not RightGrip or (RightGrip.Part0 ~= Handle and RightGrip.Part1 ~= Handle) then
		return
	end
	local character = Hit.Parent
	if character == Character then
		return
	end
	local humanoid = character:FindFirstChildOfClass("Humanoid")
	if not humanoid or humanoid.Health == 0 then
		return
	end
	local player = Players:GetPlayerFromCharacter(character)
	if player and (player == Player or IsTeamMate(Player, player)) then
		return
	end
	UntagHumanoid(humanoid)
	TagHumanoid(humanoid, Player)	
	humanoid:TakeDamage(Damage)
end


function Attack()
	Damage = DamageValues.SlashDamage
	Sounds.Slash:Play()

	if Humanoid then
		if Humanoid.RigType == Enum.HumanoidRigType.R6 then
			local Anim = Instance.new("StringValue")
			Anim.Name = "toolanim"
			Anim.Value = "Slash"
			Anim.Parent = Tool
		elseif Humanoid.RigType == Enum.HumanoidRigType.R15 then
			local Anim = Tool:FindFirstChild("R15Slash")
			if Anim then
				local Track = Humanoid:LoadAnimation(Anim)
				Trail.Enabled = true
				Track:Play(0)
				HitBoxS.Enabled = true
				EffectS.Enabled = true
				SwordLight.Brightness = 2
				task.wait(0.3)
				SwordLight.Brightness = 0
				task.wait(0.2)


				Trail.Enabled = false
			end
		end
	end	
end



Tool.Enabled = true
LastAttack = 0

function Activated()
	if not Tool.Enabled or not ToolEquipped or not CheckIfAlive() then
		return
	end
	Tool.Enabled = false
	local Tick = RunService.Stepped:wait()
	if (Tick - LastAttack < 1) then
		task.wait(0.5)
		Trail.Enabled = true
		Attack()
		HitBoxS.Enabled = true
		EffectS.Enabled = true
		SwordLight.Brightness = 2
		task.wait(0.3)
		SwordLight.Brightness = 0
		task.wait(0.2)
		
		HitBoxS.Enabled = false
		EffectS.Enabled = false
		
		Trail.Enabled = false
	else
		Trail.Enabled = true
		Attack()
		HitBoxS.Enabled = true
		EffectS.Enabled = true
		SwordLight.Brightness = 2
		task.wait(0.3)
		SwordLight.Brightness = 0
		task.wait(0.2)
		
		HitBoxS.Enabled = false
		EffectS.Enabled = false
		
		Trail.Enabled = false
	end
	
	
	LastAttack = Tick
	local SlashAnim = (Tool:FindFirstChild("R15Slash") or Create("Animation"){
		Name = "R15Slash",
		AnimationId = SlashAnimations[math.random(1, #SlashAnimations)],
		Parent = Tool
	})
	
	local LungeAnim = (Tool:FindFirstChild("R15Lunge") or Create("Animation"){
	})
	Tool.Enabled = true
	
end

function CheckIfAlive()
	return (((Player and Player.Parent and Character and Character.Parent and Humanoid and Humanoid.Parent and Humanoid.Health > 0 and Torso and Torso.Parent) and true) or false)
end

function Equipped()
	Character = Tool.Parent
	Player = Players:GetPlayerFromCharacter(Character)
	Humanoid = Character:FindFirstChildOfClass("Humanoid")
	Torso = Character:FindFirstChild("Torso") or Character:FindFirstChild("HumanoidRootPart")
	if not CheckIfAlive() then
		return
	end
	ToolEquipped = true
	Sounds.Unsheath:Play()
end

function Unequipped()
	Tool.Grip = Grips.Up
	ToolEquipped = false
end

Tool.Activated:Connect(Activated)
Tool.Equipped:Connect(Equipped)
Tool.Unequipped:Connect(Unequipped)

Connection = Handle.Touched:Connect(Blow)

do you own the animation as in did you upload it

yes I made it another test game of mine and inserted the whole model in my main game

check your output, any errors?

You need to re-upload the animations in your main game. Even if you ‘own’ the animations, the animations needs to be uploaded from the same place.

I did that, but still it isn’t working

Could you please share your animation’s settings (like priority) and your game’s data (like ownership)?
There could be many reasons.

Yes, I have set the animation priority to Action3, I have tried clearing cache but nothing changed. I have made some player avatar override changes like player scale and only r15 avatar in my game and I have even tried uploading animation from my main game. The game is a group owned game, the group is made by me and team create is on. Weird thing is that the animations only work in studio not in roblox player but I made a new place and tried this sword there and it wasn’t working in that place studio.

Though, I tried inserting classic roblox sword and it’s animation was working perfectly. I checked the output and I see any glitches.

There were no error in the output, It is completely fine, I have also checked developer console in roblox player

I see, so you reuploaded the animation to the group’s inventory?
What you described usually happens when you try to use an animation your account owns in a group game in studio, which won’t run in the Roblox Player

1 Like

No, I have uploaded it in my account right now. Wait, I’ll try uploading from my group too

I think that should do the trick, let me know.

Hey! It finally worked!! I appreciate your help buddy

1 Like

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