#I can't use math.rad(360)
1 messages · Page 1 of 1 (latest)
what you want it to be and what your game about?
It's not a game actually, it's an test. Trying to make a working slot machine but the rotations are just so annoying. Here's a clip if you want to see. (First one is 360 and other two is 180)
umm
its going back
what seems to be the issue in here?
The first one
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
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
it's rotation won't change at all if you tween like this since it's equivalent to CFrame.Angles(0,0,0)
** You are now Level 1! **
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)
i see
Don't mind the useless parts of the script here
What should I do then? I already know 360 means 0 and I'm trying to find a way that loops it around
i didn't mean your code
--// 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?
Are you asking to AI?
what do you think my code is, Ai?
I think you use help of the AI at least a little bit, not so sure. Also it does not work at all since the tween plays once and then don't look for the changed values
--// 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
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
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)