Creating a object placement system similar to SCP-3008

I’ve been trying to create a object grab and placement system similar to the one in SCP-3008, I was able to create target detection, hold trigger, and highlighting (outline), however one big issue I’ve encountered is trying to position the object.

I do not know how, I’ve already tried searching the Developer Forum however none of the posts that came up on the search was the behavior I desire, and adding on the fact that I lack knowledge on using CFrames makes this more difficult.

I’m not really asking for you to provide code, I’m just asking, how should I achieve this?

1 Like

If you want to know what I currently have for the movement, it’s this but as you can see it’s definitely not similar to the one in SCP-3008 and it’s stuck on one axis (I believe?)

local function TranslateMousePosTo3dSpace(blacklist: {BasePart}, directionMultiplier: number?)
	local MouseRay = workspace.CurrentCamera:ViewportPointToRay(Mouse.X, Mouse.Y)
	local MouseRaycastParam = RaycastParams.new()
	MouseRaycastParam.FilterType = Enum.RaycastFilterType.Blacklist
	MouseRaycastParam.FilterDescendantsInstances = blacklist
	return workspace:Raycast(MouseRay.Origin, MouseRay.Direction * (directionMultiplier or 1000), MouseRaycastParam)
end

--// CurrentTarget = The current object being held (can be a model or part)
--//  CurrentTargetBlacklist = Table with target part(s)
local RaycastResult = TranslateMousePosTo3dSpace(CurrentTargetBlacklist, 2000)
if (not RaycastResult) then return end
CurrentTarget:PivotTo(CFrame.new(Vector3.new(RaycastResult.Position.X, RaycastResult.Position.Y, RaycastResult.Position.Z)))

For reference, heres the one in SCP-3008:

You might want to try making it non cancollide and anchored as your moving it to avoid making it run into stuff and move away from mouse.

For some reason, doing this makes the object fling

Nevermind found the cause

This requires a part infront of the player if I use raycast, I want it to be placeable only at a set distance and be able to hover it to the air

I’ve found the following code positions the part to the center of the mouse: (the CFrame.Angles is for orientation reset)

CurrentTarget:PivotTo(CFrame.new(Vector3.new(Mouse.Hit.X, Mouse.Hit.Y, Mouse.Hit.Z)) * CFrame.Angles(0, 0, 0))

Now I need a way to make it to be at a specific distance only

As for the distance limit, I figured I could do something like this, now I just need to make the part align to the surface while aligned to the mouse aswell, anyone got a good idea on how to do this?
image

CurrentTarget:PivotTo(DistanceLimitFront.CFrame:ToWorldSpace(CFrame.new(0,0,0)))

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