Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How can I change the tween speed during the tween?

Asked by 3 years ago

I am making a reactor for a game and it has rings around it that will spin around the core ((yes, I know it is cliché, whatever)) but I don't want them to start and stop spinning instantly, I want to make them start slow and speed up to speed and slow down to stop. I have tried using a number value to set the speed but when the number in the value changes, the tween speed doesn't change with it. This is the code I have for spinning the ring, it works when the speed is a set speed but as I said previously, doesn't change with the number value.

local TweenService = game:GetService("TweenService")

local ring = script.Parent
local root = ring.PrimaryPart

local speed = script.Parent.Parent.speed 
--number value starts at 10 ((different script subtracts 1 with every click))

local TweenInfoSpin = TweenInfo.new(
    (speed.Value),
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.Out,
    -1,
    false,
    0
)

local TweenSpin = TweenService:Create(root, TweenInfoSpin, {CFrame = root.CFrame * CFrame.Angles(math.rad(180), 0, 0)})

TweenSpin:Play()
0
I dont think its possible, since you can't modify the TweenInfo that was initially put inside. Have you tried for loops? They're a bit less smooth but they work just fine. RAFA1608 543 — 3y

Answer this question