I’m trying to make a tool that drops piano’s from the sky, and with that tool comes a part named “pianoMark” that visually marks down where the piano will fall, an issue with it that I’ve been trying to solve for a while now though is that the piano mark just kind of floats mid air, and it doesn’t stay on the ground. I’ve attempted once again to come up with a solution by firing down a raycast on another part named “initialPosition” which is where we will get our initial CFrame from, and then after that I try making the pianoMark’s CFrame relative to the initialPosition’s CFrame, while also getting the Y axis of the raycast so that I can correctly make it stay on the ground. But this hasn’t work, and I’ve received a more broken looking effect.
What should I do?
function pianoMarkPosition()
local initialPosition = Tool:FindFirstChild("initialPosition") -- A part that I'm trying to use to raycast downwards and have its cframe be in front of the player
initialPosition.Anchored = true
initialPosition.CFrame = Player.Character.PrimaryPart.CFrame * CFrame.new(0, 0, basePianoMarkDistance + -pianoMarkMultiplier)
raycastResult = workspace:Raycast(initialPosition.Position, Vector3.new(0, -1000, 0))
if raycastResult then
if raycastResult.Instance:IsA("Part") then
pianoMark:PivotTo(initialPosition.CFrame * CFrame.new(0, raycastResult.Position.Y, 0)) -- formula for the position of the pianoMark
end
end
end
Could you provide the tool or a screenshot of what it’s doing and what you’re intending it to look like? I notice the InitialPosition is a part inside of the tool, is there a reason you do that instead of creating a part that can be cleaned up with Debris?