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)
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)
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.