I put the Union part with the other part and clicked it to move, but apparently when it touches the part, it like goes up and turns to have free space. But I want it to stand still and not move at all. Here is the link for what script BlueTaslem made if you want me to add it to make the Union part still. I just want to know how do I make the Union part still while it rotates and still stand still even though it touched the part.
Link: https://scriptinghelpers.org/questions/19967/why-does-this-script-doing-something-different-than-i-expected-and-can-you-fix-it-like-i-said
Sorry about that. @BlueTaslem, thanks for helping me. I hope everyone understands. Again, I want the Union to stand still while it rotates even though it touched the part. The Union touched the part and it like goes up to the empty space area to rotate the rest. Please help.
So considering that this is the following code in question:
for t = 0, 4.8, 0.03 do wait(0.03) local v = math.cos(t / 4.8 * math.pi) * 45 + 90 + 45 cover.CFrame = home cover.Rotation = Vector3.new(v, 0, 180) end
In ROBLOX, when Rotation is edited, ROBLOX checks if the part is intersecting another part and if it is, it will move the part upwards to stop this. To fix this, we need to use CFrame to negate the effect of ROBLOX moving the part up, but how do we use CFrame when we're trying to change the rotation?
The answer is CFrame.Angles. CFrame.Angles is a method that allows you to specify angles (in radians) to rotate the CFrame by said angle.
Rotation is a Vector3, but we're specifying angles in degrees when using Rotation, which we'll need to convert to radians in order for it to work as intended, but how do we make an angle in degrees into radians?
Well, there's a neat function called math.rad which takes a number that should be an angle in degrees and converts it into radians.
Overall, your script should now look like this:
for t = 0, 4.8, 0.03 do wait(0.03) local v = math.cos(t / 4.8 * math.pi) * 45 + 90 + 45 cover.CFrame = home * CFrame.new(math.rad(v), 0, math.pi) --Math.pi in radians is equal to half a turn, or 180 degrees. end
I hope my answer helped you. If it did, be sure to accept it.