Variable not changing on a server script

Why isnt my speed variable updating :upside_down_face: ??

seat:GetPropertyChangedSignal("Throttle"):Connect(function()
	if seat.Throttle > 0 and speed.Value < properties.MaxForward.Value then
		repeat
			speed.Value += 0.5
			task.wait(.05)
		until seat.Throttle <= 0 or speed.Value >= properties.MaxForward.Value
	elseif seat.Throttle < 0 and speed.Value > -properties.MaxBackwards.Value then
		repeat
			print(speed.Value)
			speed.Value = speed.Value - .5
			print(speed.Value)
			task.wait(.02)
		until seat.Throttle >= 0 or speed.Value <= -properties.MaxBackwards.Value
	elseif seat.Throttle == 0 then
		if speed.Value > 0 then
			repeat
				speed.Value -= 0.5
				task.wait(.05)
			until seat.Throttle > 0 or seat.Throttle < 0 or speed.Value == 0
		elseif speed.Value < 0 then
			repeat
				speed.Value += 0.5
				task.wait(.05)
			until seat.Throttle > 0 or seat.Throttle < 0 or speed.Value == 0
		end
	end
end)

It prints 15 15 even when throttle is -1, i checked all the variables, its printing 15, 15 in the output, why???

VehicleSeat.Throttle is deprecated and not replicated across the server. Try replacing it with VehicleSeat.ThrottleFloat (returns a decimal, of course).

1 Like

I fixed it, I was using throttle because i needed a flat input not a decimal, somehow this code works and the other doesnt I rewrote everything since I took this from an old video, heres the working version :

if seat.Throttle > 0 then
	repeat
	speed.Value += 1
	task.wait(.1)
	until seat.Throttle <= 0
elseif seat.Throttle < 0 then
	repeat
	speed.Value -= 1
	task.wait(.1)
	until seat.Throttle >= 0
elseif seat.Throttle == 0 then
	if speed.Value > 0 then
		repeat
			speed.Value -= 1
			task.wait(.1)
		until speed.Value == 0 or seat.Throttle ~= 0
	elseif speed.Value < 0 then
		repeat
			speed.Value += 1
			task.wait(.1)
		until speed.Value == 0 or seat.Throttle ~= 0
	end
end

Thanks though

EDIT: Ok i figured it out for real this time… It was just that i was adding 0.5 to an integerValue :man_facepalming:

1 Like

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