This script is moving a box, full of unanchored cubes, and the box keeps going all sijnhfdibdsfi, and not staying upright. How do I make the box stay upright?
01 | local ts = game:GetService( "TweenService" ) |
02 | local p 1 = script.Parent.Parent.rollmove.RI |
03 | local p 2 = script.Parent.Parent.rollmove.RII |
04 | local box = script.Parent.Parent.rollmove.Box |
05 | local click = script.Parent.ClickDetector |
06 |
07 | local function roll() |
08 | script.Parent.SurfaceGui.Rolling.Visible = true |
09 | script.Parent.SurfaceGui.Roll.Visible = false |
10 | wait() |
11 | local function moveItem(item, wp) |
12 | local ti = TweenInfo.new( 2 , Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0 , false , 0 ) |
13 | local tween = ts:Create(item, ti, { Position = wp.Position } ) |
14 | tween:Play() |
15 | wait( 2 ) |
If you can, can you tell me how to rotate the box upsidown so i can pour the cubes? (which are dice lol)
Hi, If the box is unanchored that will happen, so make sure to anchor the box that are carrying the dice! And to rotate the box upside down, you can use CFrame.Angles().
so if you want to box to rotate 90 degrees on the Y-Axis, you can just write in this simple code!
1 | local box = game.worspace.Box |
2 | tragetcframe = CFrame.Angles( 0 ,math.rad( 90 ), 0 ) |
3 | box.CFrame = targetcframe |
4 |
5 | -- always use math.rad to define an angle in Cframe.Angles!! |
put this code in a script in workspace