How should I fix this position issues?

image
Here’s the image of my game when I create rock on the roof or smth , the position dosent fit .

			local Rock = Instance.new("Part",workspace.Effects.Low)
			local RNumber = math.random(3,4)
			Rock.Size = Vector3.new(RNumber,RNumber,RNumber)
			Rock.CFrame = newCFrame * CFrame.Angles(0,math.rad(angle),0) * CFrame.new(0,0,-7.5)
			Rock.Orientation = Vector3.new(math.random(-180,180),math.random(-180,180),math.random(-180,180))
			Rock.Anchored = true
			Rock.CanCollide = false

			Rock.Color = Raycast.Instance.Color
			Rock.Material = Raycast.Material

			task.spawn(function()
				task.wait(5)
				game.TweenService:Create(Rock,TweenInfo.new(2),{CFrame = Rock.CFrame * CFrame.new(0,-7.5,0)}):Play()
				game.TweenService:Create(Rock,TweenInfo.new(1),{Transparency = 1}):Play()
				task.wait(1.1)
				Rock:Destroy()
			end)
			angle += 360/16
1 Like

We need more details.

Character Limit

You need to take into account Raycast.Normal to rotate the parts.

local rotateCf = CFrame.new(Raycast.Position, fwdVector, Raycast.Normal)
Rock.CFrame = rotateCf * CFrame.Angles(0,math.rad(angle),0) * CFrame.new(0,0,-7.5)

Where fwdVector must not have the same direction as Raycast.Normal, you could pick two vectors like Vector3.xAxis and Vector3.yAxis and pick the first one whose direction is not the same as the normal.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.