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

Can a Tween Perform a Rotation over 360 Degrees?

Asked by 4 years ago

I am trying to make a wheel that spins and then lands on a certain spot; however, even though I want it to do two full rotations before landing on a random spot, it always just tweens "most effectively" by simply rotating directly to its end location. Is there a way to make it do two full rotations first, then proceed with another semi rotation? This is what I have so far.

local Model = script.Parent.Parent.Wheel
local Part = Model.PrimaryPart
local TS = game:GetService'TweenService'
local RS = game:GetService'RunService'
local Info = TweenInfo.new(.25, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut, 0, false, 0)

local function TM(Model, CF)
    local DummyValue = Instance.new'CFrameValue'
    DummyValue.Value = Model:GetPrimaryPartCFrame()
    DummyValue:GetPropertyChangedSignal'Value':Connect(function()
        Model:SetPrimaryPartCFrame(DummyValue.Value)
    end)
    local Tween=TS:Create(DummyValue, Info, {Value = CF})
    Tween:Play()
    Tween.Completed:Wait()
    DummyValue:Destroy()
end

local SVal = Model:GetPrimaryPartCFrame()

function onClicked()
    math.randomseed(tick()) -- Generating random seed.
    local rand_spin = math.random(720, 1080) -- two full spins and somewhere on the third it will land.
    TM(Model, Part.CFrame * CFrame.Angles(math.rad(rand_spin), 0, 0))
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
0
Use BodyAngularVelocity OnaKat 444 — 4y

Answer this question