Replacing Anim Packs for part of a game

  1. What do you want to achieve?
    ~ Animations play when player is riding horse.

  2. What is the issue?
    ~ Standard animations are replaced, but any character with a purchased Anime Pack does not see the animations.

  3. What solutions have you tried so far?
    ~ Google/Dev Forum, tried getting a friend with an anime pack into the studio to see if it changed the anim names in the humanoid.

I can’t figure out how to show video, but basically: Player equips horse via proximityPrompt, which creates a motor6d between the HRP of the player and the horse. The horse then runs/walks/jumps as controlled, playing animations, until the player dismounts.
That’s all working beautifully.

Until someone has a purchased anim bundle, which is preventing the horse from animating and results in them walking around with a rather stylish, but useless, horse-hat…

I couldn’t get vid to load but this screenshot shows two people on horses, one without an anim pack (on the black horse, nicely seating and anim working), and one with the OldSkool Anim Pack equipped, also “mounted to the (white) horse” but actually stuck under the horse due to the anim not working.

Anims are already set at high action… I tried finding anime pack IDs but that didn’t seem to work… How can I override paid anims just for when riding the horse?

Here is the anim control script in starterplayer, in case it’s relevant:

local character = script.Parent
local Humanoid = 	character:WaitForChild("Humanoid")
local Animate = 	character:WaitForChild("Animate")

local runValue = 	Animate:WaitForChild("run")
local idleValue = 	Animate:WaitForChild("idle")
local jumpValue = 	Animate:WaitForChild("jump")
local walkValue = 	Animate:WaitForChild("walk")

local player = game.Players.LocalPlayer
local Mount = player:WaitForChild("MountHorse")

local run_id = 		runValue:WaitForChild("RunAnim").AnimationId
local idle_id1 = 	idleValue:WaitForChild("Animation1").AnimationId
local idle_id2 = 	idleValue:WaitForChild("Animation2").AnimationId
local jump_id = 	jumpValue:WaitForChild("JumpAnim").AnimationId
local walk_id = 	walkValue:WaitForChild("WalkAnim").AnimationId 

local climbing_anim = 	Instance.new("Animation", script)
local idle_anim = 		Instance.new("Animation", script)
local run_anim = 		Instance.new("Animation", script)
local jump_anim = 		Instance.new("Animation", script)
local walk_anim = 		Instance.new("Animation", script)
local gallop_anim = 	Instance.new("Animation", script)

local idle_loaded
local running_loaded
local jump_loaded
local walk_loaded
local gallop_loaded

local availwalktype = {"slow", "normal", "gallop"}
local walktype

local speeds = {6, 16, 32}

local SPEED_SLOW = 1
local SPEED_NORMAL = 2
local SPEED_GALLOP = 3

local footsteps = nil

local ContextActionService = game:GetService("ContextActionService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")

local MountEvent = ReplicatedStorage:WaitForChild("MountEventHorse")

local init = false


local function toggleCameraMode(inputname, inputstate)
	if inputstate ~= Enum.UserInputState.Begin then return end
	local camera = game.Workspace.CurrentCamera
	if player.CameraMode == Enum.CameraMode.Classic then
		player.CameraMode = Enum.CameraMode.LockFirstPerson
	else
		player.CameraMode = Enum.CameraMode.Classic
	end
end

--ContextActionService:BindAction("ToggleCamera", toggleCameraMode, true, Enum.KeyCode.F)

local function ChangeWalkSpeed(Player, NewWalkSpeed)
	if Player and Player.Character then
		if Player.Character:FindFirstChildWhichIsA("Humanoid") then
			if Player.Character:FindFirstChildWhichIsA("Humanoid").WalkSpeed ~= NewWalkSpeed then
				Player.Character:FindFirstChildWhichIsA("Humanoid").WalkSpeed = NewWalkSpeed
				for i, val in ipairs(speeds) do
					if val == NewWalkSpeed then
						walktype = availwalktype[i]
					end
				end
				print("New Walkspeed: ", NewWalkSpeed)
			end
		end
	end
end

local function UnmountFromHorse()
	if idle_loaded then 
		idle_loaded:Stop() 
	end
	if running_loaded then 	
		running_loaded:Stop() 
		running_loaded = nil
	end
	if jump_loaded then 
		jump_loaded:Stop() 
	end
	if walk_loaded then 
		walk_loaded:Stop() 
		walk_loaded = nil
	end
	if gallop_loaded then
		gallop_loaded:Stop()
		gallop_loaded = nil
	end
	MountEvent:FireServer("Unmount")
end

Mount:GetPropertyChangedSignal("Value"):Connect(function() 
	if Mount.Value ~= nil then -- player is on a mount
		local horse = Mount.Value

		climbing_anim.AnimationId = "rbxassetid://"..horse:GetAttribute("Climbing")
		idle_anim.AnimationId = 	"rbxassetid://"..horse:GetAttribute("Idle")
		run_anim.AnimationId = 		"rbxassetid://"..horse:GetAttribute("Running")
		jump_anim.AnimationId = 	"rbxassetid://"..horse:GetAttribute("Jump")
		walk_anim.AnimationId = 	"rbxassetid://"..horse:GetAttribute("Walk")
		gallop_anim.AnimationId = 	"rbxassetid://"..horse:GetAttribute("Gallop")

		idle_loaded = 	 Humanoid:LoadAnimation(idle_anim)
		running_loaded = Humanoid:LoadAnimation(run_anim)
		jump_loaded =    Humanoid:LoadAnimation(jump_anim)
		walk_loaded =    Humanoid:LoadAnimation(walk_anim)
		
		local climbing_loaded = Humanoid:LoadAnimation(climbing_anim)
		gallop_loaded = Humanoid:LoadAnimation(gallop_anim)
		climbing_loaded:Play()		
		idle_loaded:Play()
		climbing_loaded.Ended:Wait()
-- Debris after Ended ????? What ? Why ?
		game:GetService("Debris"):AddItem(climbing_anim, .3)
		footsteps = horse:FindFirstChild("Footsteps") or nil
		walktype = availwalktype[SPEED_NORMAL]
		ChangeWalkSpeed(player, speeds[SPEED_NORMAL])
	else --the player got off the mount
		--runValue.RunAnim.AnimationId = run_id
		--idleValue.Animation1.AnimationId = idle_id1
		--idleValue.Animation2.AnimationId = idle_id2		
		if running_loaded then
			running_loaded:Stop()
		end
		if idle_loaded then
			idle_loaded:Stop()
		end
		if walk_loaded then
			walk_loaded:Stop()
		end
		footsteps = nil
	end
end)

Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
	if Mount.Value then
		if Humanoid.MoveDirection.Magnitude > 0 then --player is moving
			if walktype == availwalktype[SPEED_NORMAL] then
				if running_loaded and not running_loaded.IsPlaying then
					walk_loaded:Stop()
					gallop_loaded:Stop()
					running_loaded:Play()
					print("Running_loaded play")
				end
			elseif walktype == availwalktype[SPEED_SLOW] then
				if walk_loaded and not walk_loaded.IsPlaying then
					running_loaded:Stop()
					gallop_loaded:Stop()
					walk_loaded:Play()
					print("walk_loaded play")
				end
			else
				-- Galopp goes here
				if gallop_loaded and not gallop_loaded.IsPlaying then
					running_loaded:Stop()
					walk_loaded:Stop()
					gallop_loaded:Play()
					print("gallop_loaded play")
				end
			end
			--if running_loaded and not running_loaded.IsPlaying then
			--	walktype = availwalktype[SPEED_NORMAL]
			--	running_loaded:Play()
			--end
			if Mount.Value and footsteps and not footsteps.Playing then
				footsteps:Play()
			end
			--if jump_loaded then
			----	jump_loaded:Play()
			--end		
		else --player stopped moving
			if footsteps then
				footsteps:Stop()
			end
			if walktype == availwalktype[SPEED_NORMAL] then
				if running_loaded and running_loaded.IsPlaying then
					running_loaded:Stop()
				end
			elseif walktype == availwalktype[SPEED_SLOW] then
				if walk_loaded and walk_loaded.IsPlaying then
					walk_loaded:Stop()
				end
			else
				-- Galopp goes here
				if gallop_loaded and gallop_loaded.IsPlaying then
					gallop_loaded:Stop()
				end
			end	
			--if running_loaded and running_loaded.IsPlaying then
			--	running_loaded:Stop()
			--end
		end
	end
end)

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Tab then
		if Mount.Value then --if the player is on a horse
			UnmountFromHorse()
		end
	end
	-- Space should be jumping
	if input.KeyCode == Enum.KeyCode.Space then
		if Mount.Value then
			if walktype == availwalktype[SPEED_NORMAL] then
				if jump_loaded and running_loaded.IsPlaying then
					running_loaded:Stop()
					gallop_loaded:Stop()
					jump_loaded:Play()
				end
			elseif walktype == availwalktype[SPEED_SLOW] then
				if jump_loaded and walk_loaded.IsPlaying then
					walk_loaded:Stop()
					gallop_loaded:Stop()
					jump_loaded:Play()
				end
			else
				-- Galopp goes here
				if jump_loaded and gallop_loaded.IsPlaying then
					walk_loaded:Stop()
					gallop_loaded:Stop()
					jump_loaded:Play()
				end
			end
		end
	end
	if input.KeyCode == Enum.KeyCode.LeftShift then
		-- Change Walkspeed to Galoppspeed
		ChangeWalkSpeed(player, speeds[SPEED_GALLOP])
	end
	if input.KeyCode == Enum.KeyCode.LeftControl then
		ChangeWalkSpeed(player, speeds[SPEED_SLOW])
	end
end)

UserInputService.InputEnded:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.LeftShift or input.KeyCode == Enum.KeyCode.LeftControl then
		if input.KeyCode == Enum.KeyCode.LeftShift then
			if gallop_loaded and gallop_loaded.IsPlaying then
				gallop_loaded:Stop()
			end
		end
		if input.KeyCode == Enum.KeyCode.LeftControl then
			if walk_loaded and walk_loaded.IsPlaying then
				walk_loaded:Stop()
			end
		end
		ChangeWalkSpeed(player, speeds[SPEED_NORMAL])
	end
end)

local function activateMobileInput(enable:boolean)
	if enable then
		if not init then
			--Mobile Controllability
			if UserInputService.TouchEnabled then
				ContextActionService:BindAction('Horse_Dismount', (function()
					UnmountFromHorse()
				end), true, Enum.KeyCode.R)
				ContextActionService:SetTitle("Horse_Dismount", "Dismount")
				ContextActionService:SetPosition('Horse_Dismount', UDim2.new(0, 180, 0, -120))
				--ContextActionService:SetSize('Horse_Dismount', UDim2.new(0, 40, 0, 40))
				ContextActionService:GetButton('Horse_Dismount').ImageColor3 = Color3.fromRGB(180, 255, 255)
				
				ContextActionService:BindAction('Horse_SlowWalk', (function()
					ChangeWalkSpeed(player, speeds[SPEED_SLOW])
				end), true, Enum.KeyCode.LeftControl)
				ContextActionService:SetTitle("Horse_SlowWalk", "Slow Walk")
				ContextActionService:SetPosition('Horse_SlowWalk', UDim2.new(0, 180, 0, -70))
				--ContextActionService:SetSize('Horse_SlowWalk', UDim2.new(0, 40, 0, 40))
				ContextActionService:GetButton('Horse_SlowWalk').ImageColor3 = Color3.fromRGB(0, 255, 0)
				
				ContextActionService:BindAction('Horse_Gallop', (function()
					ChangeWalkSpeed(player, speeds[SPEED_GALLOP])
				end), true, Enum.KeyCode.LeftShift)
				ContextActionService:SetTitle("Horse_Gallop", "Gallop")
				ContextActionService:SetPosition('Horse_Gallop', UDim2.new(0, 180, 0, 30))
				--ContextActionService:SetSize('Horse_Gallop', UDim2.new(0, 40, 0, 40))
				ContextActionService:GetButton('Horse_Gallop').ImageColor3 = Color3.fromRGB(180, 0, 0)
				
				ContextActionService:BindAction('Horse_Normal', (function()
					ChangeWalkSpeed(player, speeds[SPEED_NORMAL])
				end), true )
				ContextActionService:SetTitle("Horse_Normal", "Normal")
				ContextActionService:SetPosition('Horse_Normal', UDim2.new(0, 180, 0, -20))
				--ContextActionService:SetSize('Horse_Normal', UDim2.new(0, 40, 0, 40))
				ContextActionService:GetButton('Horse_Normal').ImageColor3 = Color3.fromRGB(255, 133, 0)
			end
			init = true
		end
	else
		if init then
			if ContextActionService:GetAllBoundActionInfo()['Horse_Dismount'] then 
				ContextActionService:UnbindAction('Horse_Dismount')
			end
			if ContextActionService:GetAllBoundActionInfo()['Horse_SlowWalk'] then
				ContextActionService:UnbindAction('Horse_SlowWalk')
			end
			if ContextActionService:GetAllBoundActionInfo()['Horse_Gallop'] then 
				ContextActionService:UnbindAction('Horse_Gallop')
			end
			if ContextActionService:GetAllBoundActionInfo()['Horse_Normal'] then 
				ContextActionService:UnbindAction('Horse_Normal')
			end
			init = false
		end
	end
end

game.Players.LocalPlayer.PlayerGui.ScreenOrientation = Enum.ScreenOrientation.LandscapeSensor

while task.wait(.5) do
	if game.ReplicatedStorage:WaitForChild("HorseActive").Value then
		activateMobileInput(true)
	else
		activateMobileInput(false)
	end
end

If anyone would like to see the horse anims, especially if you have an anim pack to replicate the issue, there’s a “working horse” game public on my profile you’re welcome to join and see what I mean more clearly.

Thank you.

Your approach involves to override any animation pack that player is using and just using the animations you have for mounting the horse?

Or you want to keep some of the animations that the player has in their animation pack?

I could infer more if I read your script in more detail, Im sorry I cant do it right now, just trying to help a little/as possible making questions (I already read it quickly seems a little hardcoded and some variables not really used, along with setting animation IDs as needed on mount on Properties that got changed by a script context that you didnt shared)

So the script as-is creates a climbing animation for the player to actually climb onto the horse when the ProximityPrompt is triggered.
It then overrides the standard idle, walk, run, and jump animations used by every Roblox character, replacing them with custom animations loaded in via attributes in the horse properties.

The rest of the animations are not mentioned as they are not used when riding the horse (swim and fall and all those extras would just play the standard anims as there are no replacements for them).

So the standard animations replaced are overridden and working. It’s just if someone with one of these things tries to ride the horse…

… These are not overridden by the script/attributes so the player doesn’t “ride” the horse, they just stand inside the horse and run around with it sitting on them.

Appreciate the reply, all questions are welcome on the road to finding the answer :slight_smile:

As far as I know, there’s no other script or anything missing. The only other scripts involved are the ones to register the ProximityPrompt, and to create the motor6d connection between player and horse. They don’t mention the anims at all, although I could certainly post them here if there’s a chance they might be relevant.

2 Likes

I found all the anim IDs on Roblox documents, so thought maybe I could script each individual anim change (except bold and oldschool which are not listed).

Except the anim IDs currently being used, and the IDs in the document appear to not match, so, that’s helpful…

Surely there must be some way to remove/override all purchased anims??