Changing horse speed

I’ve been trying to write a horse speed changing system forever now, and I can get the horse to walk around, but can’t actually change speed. If you could provide me some pointers or move me in the right direction, it’ll be greatly appreciated!

UserInputService.InputBegan:Connect(function(input)
	if input == Enum.KeyCode.LeftShift then
		print("galloping")
		value = 'gallop'
		cantering = false
	elseif input == Enum.KeyCode.LeftControl then
		value = 'walk'
		print("walking")
		cantering = false
	end
end)

--server script

value.Changed:Connect(function(input)
		if input == 'gallop' then
			print("galloping")
			gallop()
		elseif input == 'canter' then
			print("cantering")
			canter()
		elseif input == 'walk' then
			print("walking")
			walk()
		end
	end)

note, i’ve tried remote events in replicated storage or in the horse, neither worked and this is just values that don’t work either

1 Like

i’ve been using this horse model and editing off it. https://create.roblox.com/store/asset/9865824417/Working-Horse?viewFromStudio=true&keyword=horse&searchId=1A974ACE-D2A4-4655-A9F6-0131B776024A

you are using a local script to change the value, since it is not changing on the server, the server script is unable to detect a change.

the value is not replicating to the server you need to modify it there, you can use remote events, but you said that you already used it so can you explain how you used them?

i had used a local script that sent out a text specifying which mode the horse should switch to, and the server sided script had responded by doing said action by doing the local function corresponding to it.

i had moved the changing value part of the local script to a script and had the same effect, nothing changed

i suggest doing

-- local
RemoteEvent:FireServer("Gallop")

-- server
RemoteEvent.OnServerEvent:Connect(function(moveType)
   if moveType == "Gallop" then
      gallop()
   elseif moveType == "Canter" then
      canter()
   end
end)```

and so on

my bad im new to dev forum need to get used to the formats

i’ve already tried this, it doesn’t work

for some reason, whenever i start putting in if statements then the input service doesn’t work

UserInputService.InputBegan:Connect(function(input)
	print("hey")
end)

compared to

UserInputService.InputBegan:Connect(function(input)
	if input == Enum.KeyCode.Q then
--so and so
end)

it doesn’t work, and returns blank.

Ah, I only noticed now that you have been using “input” rather than “input.KeyCode”.
input.KeyCode returns the actual key/button being pressed

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