#I can't use math.rad(360)

1 messages · Page 1 of 1 (latest)

hoary shale
#

When I try to turn the part 360° it just thinks I said 0° since 360° and 0° is at the same place. I can't find a solution for this, the thing I'm trying to do is turn the part 360° like a full loop around it self.

{
    CFrame = Spinny1.CFrame * CFrame.Angles(math.rad(360),0,0)
}
fossil lotus
hoary shale
fossil lotus
#

its going back

#

what seems to be the issue in here?

hoary shale
#

The first one is not doing a loop

#

I want it do to a full loop around it self

#

like go bottom and come back from top

fossil lotus
#
local TweenService = game:GetService("TweenService")
local Spinny1 = workspace.Spinny1 -- put the path of the handle in here

local spinTime = 2 -- amount of time

-- Loop forever
while true do
    local startCFrame = Spinny1.CFrame
    local goalCFrame = startCFrame * CFrame.Angles(math.rad(360), 0, 0)

    local tweenInfo = TweenInfo.new(spinTime, Enum.EasingStyle.Linear)
    local tween = TweenService:Create(Spinny1, tweenInfo, {CFrame = goalCFrame})
    
    tween:Play()
    tween.Completed:Wait()

    -- Reset back to original orientation to prevent floating-point buildup
    Spinny1.CFrame = startCFrame
end
fluid flicker
#

it's rotation won't change at all if you tween like this since it's equivalent to CFrame.Angles(0,0,0)

ivory mulchBOT
#

studio** You are now Level 1! **studio

hoary shale
# fossil lotus ```lua local TweenService = game:GetService("TweenService") local Spinny1 = work...

If I send you the code it will be more helpful I think because I can't use while true do here

--// Services
local TS = game:GetService("TweenService")

--// Stats
local Spinny1,Spinny2,Spinny3 =
    script.Parent.Spinny1.Decor,
    script.Parent.Spinny2.Decor,
    script.Parent.Spinny3.Decor

--// Tween
local TInfo = TweenInfo.new(1,
    Enum.EasingStyle.Circular,
    Enum.EasingDirection.In,
    0,
    false,
    1
)

local TGoal,TGoal2,TGoal3 = 
{
    CFrame = Spinny1.CFrame * CFrame.Angles(math.rad(360),0,0)
},
{
    CFrame = Spinny2.CFrame * CFrame.Angles(math.rad(180),0,0)
},
{
    CFrame = Spinny3.CFrame * CFrame.Angles(math.rad(180),0,0)
}

--// Remotes
local RollStarted = game.Workspace["Slot Machine"].Remotes.RollStarted

--// Rolled
local function Roll()
    local SpinTween1 = TS:Create(Spinny1, TInfo, TGoal);SpinTween1:Play()
    task.wait(0.5)
    local SpinTween2 = TS:Create(Spinny2,TInfo,TGoal2);SpinTween2:Play()
    task.wait(0.5)
    local SpinTween3 = TS:Create(Spinny3,TInfo,TGoal3);SpinTween3:Play()
end

RollStarted.Event:Connect(function()
    Roll()
end)
hoary shale
hoary shale
fluid flicker
fossil lotus
# hoary shale What should I do then? I already know 360 means 0 and I'm trying to find a way t...
--// Services
local TS = game:GetService("TweenService")

--// Stats
local Spinny1 = script.Parent.Spinny1.Decor
local Spinny2 = script.Parent.Spinny2.Decor
local Spinny3 = script.Parent.Spinny3.Decor

--// Tween Info
local TInfo = TweenInfo.new(
    1,
    Enum.EasingStyle.Linear,
    Enum.EasingDirection.InOut,
    0,
    false,
    0
)

--// Remotes
local RollStarted = game.Workspace["Slot Machine"].Remotes.RollStarted

--// Spin Function
local function Roll()
    -- Spinnny1
    task.spawn(function()
        for i = 1, 360, 10 do
            Spinny1.CFrame = Spinny1.CFrame * CFrame.Angles(math.rad(10), 0, 0)
            task.wait(0.01)
        end
    end)

    -- Spinny2
    task.wait(0.5)
    local goal2 = {CFrame = Spinny2.CFrame * CFrame.Angles(math.rad(180), 0, 0)}
    local tween2 = TS:Create(Spinny2, TInfo, goal2)
    tween2:Play()

    -- Spinny3
    task.wait(0.5)
    local goal3 = {CFrame = Spinny3.CFrame * CFrame.Angles(math.rad(180), 0, 0)}
    local tween3 = TS:Create(Spinny3, TInfo, goal3)
    tween3:Play()
end

--// Event Connect
RollStarted.Event:Connect(Roll)
#

can you try this?

hoary shale
#

Are you asking to AI?

fossil lotus
#

what do you think my code is, Ai?

hoary shale
fluid flicker
#
--// Services
local TS = game:GetService("TweenService")

--// Stats
local Spinny1,Spinny2,Spinny3 =
    script.Parent.Spinny1.Decor,
    script.Parent.Spinny2.Decor,
    script.Parent.Spinny3.Decor

--// Tween
local TInfo = TweenInfo.new(1,
    Enum.EasingStyle.Circular,
    Enum.EasingDirection.In,
    0,
    false,
    1
)

local StartGoal,StartGoal2,StartGoal3 = 
    {
        CFrame = Spinny1.CFrame
    },
    
    {
        CFrame = Spinny2.CFrame
    },

    {
        CFrame = Spinny3.CFrame
    }

local TGoal,TGoal2,TGoal3 = 
    {
        CFrame = Spinny1.CFrame * CFrame.Angles(math.rad(179),0,0)
    },

    {
        CFrame = Spinny2.CFrame * CFrame.Angles(math.rad(179),0,0)
    },

    {
        CFrame = Spinny3.CFrame * CFrame.Angles(math.rad(179),0,0)
}

local ReturnTween1 = TS:Create(Spinny1, TInfo, StartGoal)
local ReturnTween2 = TS:Create(Spinny2, TInfo, StartGoal2)
local ReturnTween3 = TS:Create(Spinny3, TInfo, StartGoal3)

local SpinTween1 = TS:Create(Spinny1, TInfo, TGoal)
local SpinTween2 = TS:Create(Spinny2,TInfo, TGoal2)
local SpinTween3 = TS:Create(Spinny3,TInfo, TGoal3)

SpinTween1.Completed:Connect(function()
    Spinny1.CFrame = Spinny1.CFrame * CFrame.Angles(math.rad(2), 0, 0)
    ReturnTween1:Play()
end)

SpinTween2.Completed:Connect(function()
    Spinny2.CFrame = Spinny2.CFrame * CFrame.Angles(math.rad(2), 0, 0)
    ReturnTween2:Play()
end)

SpinTween3.Completed:Connect(function()
    Spinny3.CFrame = Spinny3.CFrame * CFrame.Angles(math.rad(2), 0, 0)
    ReturnTween3:Play()
end)

--// Remotes
local RollStarted = game.Workspace["Slot Machine"].Remotes.RollStarted

--// Rolled
local function Roll()
    SpinTween1:Play()
    task.wait(0.5)
    SpinTween2:Play()
    task.wait(0.5)
    SpinTween3:Play()
end

RollStarted.Event:Connect(Roll)
#

i've done this which basically splits it into two tweens and adds a small increment to the rotation after the first tween has finished to make sure the second tween goes in the direction we want, i'm not sure if this is the best way to approach it but i hope it works fine for you

hoary shale
#

It probably will work since you turn it 180 degree twice but I just wonder is there a better way for this instead of making 2 tweens

fluid flicker
#

i guess you could tween a number value representing the rotation between 0 and 360 instead of the part's rotation itself and use RunService.Stepped to update its rotation each frame

#
--// Services
local TS = game:GetService("TweenService")

--// Stats
local Spinny1,Spinny2,Spinny3 =
    script.Parent.Spinny1.Decor,
    script.Parent.Spinny2.Decor,
    script.Parent.Spinny3.Decor


local originalCFrame1, originalCFrame2, originalCFrame3 = Spinny1.CFrame, Spinny2.CFrame, Spinny3.CFrame

local RotationNumberValue1,RotationNumberValue2,RotationNumberValue3 =
    Instance.new("NumberValue"),
    Instance.new("NumberValue"),
    Instance.new("NumberValue")

RotationNumberValue1.Parent, RotationNumberValue2.Parent, RotationNumberValue3.Parent = Spinny1, Spinny2, Spinny3

--// Tween
local TInfo = TweenInfo.new(1,
    Enum.EasingStyle.Circular,
    Enum.EasingDirection.In,
    0,
    false,
    1
)

local SpinTween1 = TS:Create(RotationNumberValue1,TInfo,{Value = 360})
local SpinTween2 = TS:Create(RotationNumberValue2,TInfo,{Value = 360})
local SpinTween3 = TS:Create(RotationNumberValue3,TInfo,{Value = 360})


--// Remotes
local RollStarted = game.Workspace["Slot Machine"].Remotes.RollStarted

--// Rolled
local function Roll()
    RotationNumberValue1.Value, RotationNumberValue2.Value, RotationNumberValue3.Value = 0, 0, 0
    
    SpinTween1:Play()
    task.wait(0.5)
    SpinTween2:Play()
    task.wait(0.5)
    SpinTween3:Play()
end

RollStarted.Event:Connect(Roll)

game:GetService("RunService").Stepped:Connect(function()
    Spinny1.CFrame = originalCFrame1 * CFrame.Angles(math.rad(RotationNumberValue1.Value),0,0)
    Spinny2.CFrame = originalCFrame2 * CFrame.Angles(math.rad(RotationNumberValue2.Value),0,0)
    Spinny3.CFrame = originalCFrame3 * CFrame.Angles(math.rad(RotationNumberValue3.Value),0,0)
end)
late steppe
#

@hoary shale

#

You could most likely make 2 points as a variable (e.g. p1 = 180degrees, p2 = 360) or for safety, 4 points each +90 degrees

#

Then just tween it to each point at a constant rate