Problem with tween(Any help?)

When the player rotates the wheels turn around, I want the wheels to only spin and not rotate around.

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

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

local RW = script.Parent.RightWheel

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

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

humanoid.Running:Connect(function()
	if humanoid.MoveDirection.X > 0.01 then
		local moveDirection = character:GetPrimaryPartCFrame().LookVector
		local newOrientation = Vector3.new(0, 0, -360)
		tween:Cancel()
		tween2:Cancel()
		tween = ts:Create(script.Parent.LeftWheel, ti, {Orientation = newOrientation})
		tween2 = ts:Create(RW, ti, {Orientation = newOrientation})

		tween:Play()
		tween2:Play()
	elseif humanoid.MoveDirection.X < -0.01 then
		local newOrientation = Vector3.new(0, 0, 360)
		tween:Cancel()
		tween2:Cancel()
		tween = ts:Create(script.Parent.LeftWheel, ti, {Orientation = newOrientation})
		tween2 = ts:Create(RW, ti, {Orientation = newOrientation})
		tween:Play()
		tween2:Play()
	end
end)
humanoid.Running:Connect(function(speed)
	if speed == 0 then
		tween:Pause()
		tween2:Pause()
	end
	end)
2 Likes

No comment on the implementation…
but you’re really just gonna steal Blaster Master like that?
Maybe reconsider this project and try to make it your own…

1 Like

I am only making the tank, I emailed the company that made the game, nothing yet.
Once I get permission I will work on the full game

you can modify the code to use the CFrame property instead of the Orientation

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

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

local RW = script.Parent.RightWheel

local initialCFrame = character.PrimaryPart.CFrame * CFrame.Angles(0, 0, math.rad(-360))
local propertyToTween = {CFrame = initialCFrame}

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

humanoid.Running:Connect(function()
    if humanoid.MoveDirection.X > 0.01 then
        local moveDirection = character:GetPrimaryPartCFrame().LookVector
        local newCFrame = character.PrimaryPart.CFrame * CFrame.Angles(0, 0, math.rad(-360))
        tween:Cancel()
        tween2:Cancel()
        tween = ts:Create(script.Parent.LeftWheel, ti, {CFrame = newCFrame})
        tween2 = ts:Create(RW, ti, {CFrame = newCFrame})

        tween:Play()
        tween2:Play()
    elseif humanoid.MoveDirection.X < -0.01 then
        local newCFrame = character.PrimaryPart.CFrame * CFrame.Angles(0, 0, math.rad(360))
        tween:Cancel()
        tween2:Cancel()
        tween = ts:Create(script.Parent.LeftWheel, ti, {CFrame = newCFrame})
        tween2 = ts:Create(RW, ti, {CFrame = newCFrame})
        tween:Play()
        tween2:Play()
    end
end)

humanoid.Running:Connect(function(speed)
    if speed == 0 then
        tween:Pause()
        tween2:Pause()
    end
end)

The wheels aren’t spinning.

I found the problem, thanks for the help

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