Help to make a TextButton change a VehicleSeat value

The Issue
Hi. Im making a VehicleSeat car, and i wanted to make a button that basically sets your speed, but is reversible. The thing is, i don’t really know how to put it into script. I already have a lot of ideas on how to do it, but not really how to actually script it.
Some Ideas
I do know already some things about how i could go about writing this script. First of all, to change the speed of the car you only need this code:

seat.MaxSpeed = 30

And i also learned that if a value is set and the value makes it so that the VehicleSeat goes at a certain speed, the MaxSpeed cant change until the value changes.
So i thought that when the TextButton gets clicked, a function activates that detects if a value is 0, then it changes to 1. If the value is 1, the MaxSpeed changes. If the value is 0, the MaxSpeed goes back to normal. Please put your input on how i could script this.
Why i made this
I made this thread because no other thread like it existed. I thank all replies that try to help! Have a great day.

1 Like
local normal = 0
script.Parent.MouseButton1Down:Connect(function()
	if normal == 0 then
		normal = 1
		seat.MaxSpeed = normal
	else
		normal = 0
		seat.MaxSpeed = change
	end
end)

???

Thank you so much. Im going to test it out, however i think it works.

Hmm it doesnt work. When i press it nothing happens.

oh, define the variables change and seat since idk where your seat or what specific speed u want

I know how to do basic things, im not THAT bad at coding, so you dont really need the speed but if you want ig, 200 is normal and 70 is not normal, and the textbutton is called cautionlimiter

local seat = workspace.Seat --Define urself change this, find where seat is (ex: workspace.Car.Seat)
local normal = 0 --dont touch
script.Parent.MouseButton1Down:Connect(function()
	if normal == 0 then
		normal = 1
		seat.MaxSpeed = 70
	else
		normal = 0
		seat.MaxSpeed = 200
	end
end)

It works kind of. When I press it, it doesn’t change the speed, but the HeadsUpDisplay acts like if the max speed was 70. so thats a start

Hmm, the properties tab also says that the max speed is 70 but im still going at 200.

is the script a client sided??, if it is I suggest turning server sided by using a normal script instead of a client

Its a localscript, should i make it a normal one?

IT WORKED BY CHANGING IT TO A NORMAL ONE! Thank you for your cooperation. I really needed this!

1 Like