Press E keybind and local vehicle seat maxspeed +1

Im needing help on a system where if you press E in the vehicle seat the maxSpeed + 1 and you can do this until it hits 25 maxspeed

ive tried it and heres what i came up with the problem was it was building up scripts in starterplayerscripts and for every vehicleseat i would be a pain:

local uis = game:GetService("UserInputService")
aa = true

uis.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.E and game.Players.LocalPlayer.Character:WaitForChild("Humanoid").SeatPart.Name == "Driver" then
		print("ELLO!")
-- type here speed +1--
			end
end)

uis.InputEnded:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.E and game.Players.LocalPlayer.Character:WaitForChild("Humanoid").SeatPart.Name == "Driver" then
print("hello!")
--type here +1 speed whatever--
		end
end)

ive looked all over the forum and cant seem to find help and i really need this so if you can help would be great!

So the script ive shown above is currentley in a localscript in starterplayerscripts but id prefer it to be in the vehicleseat itself if possible. The script from starterplayerscripts links up to the vehicleseat by a HumanoidDescription but like i said if i could just get all of it in the vehicle seat would be good.

1 Like

Could you please send a formatted version?

such as :

--your code here
3 Likes

any change to it now any help?

1 Like
local uis = game:GetService("UserInputService")
aa = true

uis.InputBegan:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.E and game.Players.LocalPlayer.Character:WaitForChild("Humanoid").SeatPart == "Driver" then
		print("ELLO!")
	end
end)

uis.InputEnded:Connect(function(key)
	if key.KeyCode == Enum.KeyCode.E and game.Players.LocalPlayer.Character:WaitForChild("Humanoid").SeatPart == "Driver" then
		print("hello!")
	end
end)

Notice:
SeatPart is an ObjectValue, thus- don’t try to get its name, but its object.

I tested the code above, and it worked

1 Like