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?
local ts = game:GetService("TweenService") local p1 = script.Parent.Parent.rollmove.RI local p2 = script.Parent.Parent.rollmove.RII local box = script.Parent.Parent.rollmove.Box local click = script.Parent.ClickDetector local function roll() script.Parent.SurfaceGui.Rolling.Visible = true script.Parent.SurfaceGui.Roll.Visible = false wait() local function moveItem(item, wp) local ti = TweenInfo.new(2, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, false, 0) local tween = ts:Create(item, ti, { Position = wp.Position}) tween:Play() wait(2) end moveItem(box, p1) moveItem(box, p2) local tragetcframe = CFrame.Angles(0,math.rad(90),0) box.CFrame = tragetcframe moveItem(box, p1) script.Parent.SurfaceGui.Rolling.Visible = false script.Parent.SurfaceGui.Roll.Visible = true end click.MouseClick:Connect(roll)
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!
local box = game.worspace.Box tragetcframe = CFrame.Angles(0,math.rad(90),0) box.CFrame = targetcframe -- always use math.rad to define an angle in Cframe.Angles!!
put this code in a script in workspace