Tween not stoping

The tween doesn’t stop when it’s supposed to(Sorry I’m new to tweens)

local character = script.Parent

local humanoid = character:WaitForChild("Humanoid")

local ts = game:GetService("TweenService")

local ti = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out,-1)

local propertyToTween = {Orientation = Vector3.new(0, 0, -360)}

local RW = script.Parent.RightWheel

local tween = ts:Create(script.Parent.LeftWheel, ti, propertyToTween)

local tween2 = ts:Create(RW, ti, propertyToTween)

humanoid.Running:Connect(function(speed)

if speed > 0 then

tween:Play()

tween2:Play()

if speed ==0 then

tween:Stop() --This is when it is supposed to stop

tween2:Stop() --This is when it is supposed to stop

end

end

end)
1 Like

I believe you have to make the second if statement into an elseif statement or an else statement.

Fixed Code:

local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")

local ts = game:GetService("TweenService")
local ti = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out,-1)

local propertyToTween = {Orientation = Vector3.new(0, 0, -360)}

local RW = script.Parent.RightWheel

local tween = ts:Create(script.Parent.LeftWheel, ti, propertyToTween)
local tween2 = ts:Create(RW, ti, propertyToTween)

humanoid.Running:Connect(function(speed)
	if speed > 0 then
		tween:Play()
		tween2:Play()
		
	else -- if 'speed' is equal to or below 0
		tween:Stop() --This is when it is supposed to stop
		tween2:Stop() --This is when it is supposed to stop
	end
end)
1 Like

Thank you, that works very good

1 Like

Also, How would I make it so that the wheels spin in the direction that the player is moving?

I am currently unsure about this as I do not have enough details about what you are trying to achieve. If this is an ongoing issue or something you’ve been struggling with for a while, you should create another topic for other people to help you out.

ok I will make a new post, thanks for the help

1 Like

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