So I am making a MOBA on Roblox and a recent bug I encountered with my simple mount script is that when the player mounts, sometimes the humanoid will trip and stay in a trip state and are stuck for a minute. Originally I had thought it was a different issue because the player looked like they were standing fine but the humanoid is definitely tripping. I was wondering if there is a better way to go about attaching a horse to my character. Currently I am just offsetting the hip height of the humanoid so it looks like they are on top of the horse. Each mount model is controlled by an AnimationController not a humanoid.
Here is my current code for more information:
function Mounting.LoadMount(human)
local Configuration = human.Parent:FindFirstChild('Configuration')
local playerOffset = Configuration.PlayerOffset.Value
local mountHipHeight = Configuration.MountHipHeight.Value
local player = game.Players:GetPlayerFromCharacter(human.Parent)
local mountId = playerMounts[player]
local mountData = getMountDataFromMountId(mountId)
local mount = mountData.figure:Clone()
local mountOffset = mount.Configuration.MountOffset.Value
local customOffset = Configuration:FindFirstChild('CustomOffset_'..mountId)
mount.Name = player.Name
mount:SetPrimaryPartCFrame(human.Parent:GetPrimaryPartCFrame())
local motor = Instance.new('Motor6D')
motor.Part0 = mount.PrimaryPart
motor.Part1 = human.Parent.HumanoidRootPart
motor.C0 = (CFrame.new(mount.PrimaryPart.SitAttachment.Position)
+ playerOffset + mountOffset + (customOffset and customOffset.Value or Vector3.new(0,0,0)))
motor.Parent = mount.PrimaryPart
mount.Parent = mountsFolder
human.HipHeight = mountHipHeight + mount.Configuration.HipHeightOffset.Value
return mount
end
Try using SetStateEnabled(). This is a function of the humanoid object that prevents the humanoid from entering specific states, like PlatformStanding.
On Roblox, that is a term for the user “falling” unexpectedly, completely losing control. Try setting the property for it it to true on your humanoid to see what I’m talking about. It’s hard to describe.
Basically, you don’t want that to be triggered when you sit on the horse, if that’s happening at all.
I know I can’t explain it that well, but you should try my solution anyway and see if it works
PlatformStanding was actually created for Skateboards many years ago, the behavior of completely losing control when the PlatformStanding state is entered is just a side effect of this state disabling things like the humanoid raycasting to find a floor and hovering above it. It might actually be worth setting PlatformStand to true to enter this state for something like mounts.
The FallingDown or Ragdoll states are the states that the Humanoid will enter when tripping.