I have a working horse that moves at a Humanoid.WalkSpeed
of 25.
When I press LShift, the Humanoid.WalkSpeed
should update to 50 (it does in the test game server, as you can see in the WalkSpeed Property Output picture).
My problem is that the Server Script code uses RunService.Heartbeat
and the Humanoid.WalkSpeed
does not update from 25. So the horse never moves any faster.
Scripts
Local Script
local ContextActionService = game:GetService("ContextActionService")
-- If player presses left shift key, this function is called by ContextActionService
local function handleAction(actionName, inputState, inputObject)
if actionName == "ShiftTest" then
if inputState == Enum.UserInputState.Begin then
print("Pressing Shift")
horse.Humanoid.WalkSpeed = 50
game:GetService("ReplicatedStorage").IsRunning:InvokeServer()
else
print("Stopped pressing shift")
horse.Humanoid.WalkSpeed = 25
game:GetService("ReplicatedStorage").IsWalking:InvokeServer()
end
end
end
-- Binding LeftShift Key to handleAction function
ContextActionService:BindAction("ShiftTest", handleAction, true, Enum.KeyCode.LeftShift)
Server Script
game:GetService("ReplicatedStorage").IsRunning.OnServerInvoke = function (player) Humanoid.WalkSpeed = 50 end
game:GetService("ReplicatedStorage").IsWalking.OnServerInvoke = function (player) Humanoid.WalkSpeed = 25 end
function Animate(Time)
...
-- Motion
if Seat.Throttle ~= -1 then
Velocity.velocity = (-Torso.CFrame.lookVector * Seat.Throttle * Humanoid.WalkSpeed*-1)
AngularVelocity.AngularVelocity = Vector3.new(0, (1.7 * -Seat.Steer), 0)--steer speed
print(Humanoid.WalkSpeed)
else
...
end
RunService.Heartbeat:connect(Animate)
Output: 25 (repeated)
Outputs
WalkSpeed stays at 25
WalkSpeed Property Output
No Shift:
With Shift:
WalkSpeed updates to 50 when Shift is pressed, but horse does not move faster. RunService
just captures speed at 25 and never updates
What I Need Help With: RunService
in Server Script needs to capture the Humanoid.WalkSpeed
changes. Currently trying Humanoid.Changed:connect
functions with no avail. I’m not sure how to tell the script that there was a change in speed. Thanks in advance