Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Union Box is going brrr and not smoothly while in tweenmovement?

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)

8 comments

0

Is the box unanchored?

0

Ok so anchor the box and put the below code in a script

0

The script goes in workspace

0

And if my answer fix the problem, please mark it as answered

0

the dice arent staying in the box when it moves, is there a way to fix that?

0

also, the box is being sent to the middle of the baseplate with ur extra script?? it didnt turn also? im also trying to make it so it only turns when it gets to p2 in the tween

0

oh k

0

If that is the case use orientation and vector3

1 answer

✓ Accepted answer

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

3 comments

0

where do i put this code? also yes the box was unachored

0

sne can u accept my fren request so we can do team create?

0

ok

This discussion is preserved as it was. New answers, comments, and votes are closed.