Sorry For Bad English, I Was Editing The Horse That I Got From Toolbox Which Is Made By Person Called “DermonDarble”, And I Decide To Make Horse Can Sprint Since It Not Has Sprint System, And When I Tested It, I Realized That It Affect On Other Player’s Horse Too. Like If I Sprint Horse, And Other Player Sprint Their Horses, It Force My Horse To Go Back Walk.
Local Control Script [There Is Folder Called “Scripts” Inside Of Horse, And This Script Is In Inside Of That “Scripts” Folder]
local userInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character.Humanoid
local horse = script:WaitForChild("Horse").Value
local horseGui = script:WaitForChild("HorseGui")
horseGui.Parent = player.PlayerGui
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
local rideAnimation = humanoid:LoadAnimation(horse.Animations.Ride)
rideAnimation:Play()
local movement = Vector3.new(0, 0, 0)
local event = game.ReplicatedStorage.HorseRuns
userInputService.InputBegan:connect(function(inputObject, gameProcessedEvent)
if not gameProcessedEvent then
if inputObject.KeyCode == Enum.KeyCode.W or inputObject.KeyCode == Enum.KeyCode.Up then
movement = Vector3.new(movement.X, movement.Y, -1)
elseif inputObject.KeyCode == Enum.KeyCode.S or inputObject.KeyCode == Enum.KeyCode.Down then
movement = Vector3.new(movement.X, movement.Y, 1)
elseif inputObject.KeyCode == Enum.KeyCode.A or inputObject.KeyCode == Enum.KeyCode.Left then
movement = Vector3.new(-1, movement.Y, movement.Z)
elseif inputObject.KeyCode == Enum.KeyCode.D or inputObject.KeyCode == Enum.KeyCode.Right then
movement = Vector3.new(1, movement.Y, movement.Z)
elseif inputObject.KeyCode == Enum.KeyCode.K then
humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
elseif inputObject.KeyCode == Enum.KeyCode.Q then
event:FireServer() --- Fire The Sprint Event
end
end
end)
userInputService.InputEnded:connect(function(inputObject, gameProcessedEvent)
if not gameProcessedEvent then
if inputObject.KeyCode == Enum.KeyCode.W or inputObject.KeyCode == Enum.KeyCode.Up then
if movement.Z < 0 then
movement = Vector3.new(movement.X, movement.Y, 0)
end
elseif inputObject.KeyCode == Enum.KeyCode.S or inputObject.KeyCode == Enum.KeyCode.Down then
if movement.Z > 0 then
movement = Vector3.new(movement.X, movement.Y, 0)
end
elseif inputObject.KeyCode == Enum.KeyCode.A or inputObject.KeyCode == Enum.KeyCode.Left then
if movement.X < 0 then
movement = Vector3.new(0, movement.Y, movement.Z)
end
elseif inputObject.KeyCode == Enum.KeyCode.D or inputObject.KeyCode == Enum.KeyCode.Right then
if movement.X > 0 then
movement = Vector3.new(0, movement.Y, movement.Z)
end
end
end
end)
spawn(function()
while horse.Seat.Occupant == humanoid do
game:GetService("RunService").RenderStepped:wait()
horse.Humanoid:Move(movement, true)
end
horseGui:Destroy()
humanoid:SetStateEnabled(Enum.HumanoidStateType.Jumping, true)
horse.Humanoid:Move(Vector3.new())
rideAnimation:Stop()
script:Destroy()
end)
Run Script [Is In Inside Of “Scripts” Folder]
local event = game.ReplicatedStorage.HorseRuns
running = false
event.OnServerEvent:Connect(function(player)
if running == false then
script.Parent.Parent.Humanoid.WalkSpeed = 35
running = true
elseif running == true then
script.Parent.Parent.Humanoid.WalkSpeed = 20
running = false
end
end)