SUPER DUPER EPIC grab system!

hey so i have this game that uses a grab system and you can use it now
https://create.roblox.com/store/asset/82759691603836/Scooters-Grab-System

features:

  • grabbing
  • grab to unanchor
  • rotation
  • distance
  • grabbing
  • mobile, console, and computer support with every feature
  • self-setup
  • super duper EASY setup
  • does not interfere with other mechanics or features your game may have
  • supports models and baseparts
  • supports every body type (duh)

disclaimer: system does not let you grab EVERYTHING. you have to tag parts/models with ‘CanGrab’ to grab them (weld together models and tag them to grab those)

demonstration:


other instructions included in the model
credit is appreciated have a good day my brotosyntheses

rate my resource brochachos
  • cool
  • i love it
  • marry me
  • mid
  • i hate it
  • never upload in community resources again you heathen
0 voters
17 Likes

Looks good! Reminds me of the lego Harry Potter game when you pick up a brick!

2 Likes

hell yeah

2 Likes

hell yeah

1 Like

There is a secret method (more so a method I came up with, that I haven’t seen anyone else use), that makes grabbing objects in third person like wayyy nicer. The idea is simple, and it’s to calculate the PointerCFrame (in my grab system, I have a “pointer” which is a blue ball that welds to grabed objects, and the pointer is what you control. I think it’s equivalent to the attachment in your code) by extending a ray from the camera, and only from the camera. An obvious downside to this approach is that, zooming in and out moves the grabbed object in and out as well, but it’s very easy to fix that. Take the distance between the camera and the character’s head, and use that to cancel out the zooming in and out. Another “downside” is that grabbed objects can very easily fall outside of the allowed grab range. In my case, objects just drop when that happens (I made it so the max distance can be like 1.4x the max distance required to start grabbing the object, so it cannot drop instantly). I actually like this downside a lot, because it makes it really easy to throw stuff around

Here is a video demonstrating how it behaves in third person

In your code, you take the head position, and add an offset to it using the direction the mouse is pointing, which is the common method

local screenPos = getCursorScreenPos()

local camera = workspace.CurrentCamera
local ray = camera:ViewportPointToRay(screenPos.X, screenPos.Y)

local direction = ray.Direction
local headPos = head.Position
local targetPos = headPos + direction.Unit * grabDistance

-- Set position target
alignPosition.Position = targetPos

This is the code I wrote to get the PointerCFrame (which is then directly passed to the AlignPosition)

local function GetPointerCFrame(CFrameOffsets)
	local Rayinfo = Camera:ScreenPointToRay(Mouse.X,Mouse.Y,0)
	local NewCamera = CFrame.lookAt(Rayinfo.Origin, Rayinfo.Origin + Rayinfo.Direction)

	local DistanceOffset = NewCamera:ToObjectSpace(Head.CFrame).Z - CFrameOffsets.CharacterOffset
	local Offset = DistanceOffset + Controls:GetScroll()
	local Angle = Controls:GetRollCFrame()
	local PointerCFrame = NewCamera*(CFrameOffsets.CameraPointOffset+Vector3.zAxis*Offset)*Angle

	return PointerCFrame
end

Where CFrameOffsets.CharacterOffset is the initial distance from the camera to the character’s head, when the player started the grab (CFrameOffsets.CharacterOffset = NewCamera:ToObjectSpace(Head.CFrame).Z)
And CFrameOffsets.CameraPointOffset is the initial CFrame offset from the camera, to the pointer

CFrameOffsets.PointerOffset = Target.CFrame:ToObjectSpace(MouseHit)
CFrameOffsets.CameraPointOffset = NewCamera:ToObjectSpace(Target.CFrame*CFrameOffsets.PointerOffset)

I don’t know why it’s defined like this. I think Target.CFrame*CFrameOffsets.PointerOffset is the same as MouseHit (which is Mouse.Hit, but modified for other reasons)

Wrote this reply in hopes it can help. I don’t know if this would work well for mobile, or if it’s a behavior you even want, but I think it could improve your grab system :P. I would like to open source my own grab system, but it’s not quite there (and I don’t have the time), it has poor mobile support, and my attempt at preventing flying didn’t work quite well. I would be willing to share a local file if anyone is interested
My grab script is also a bit overbuilt. it’s (over)filled with features. I like that yours is concise

Also, another tip, roblox added a RunContex property to scripts, which allows scripts to run under any container. It is particularly useful for modules, where you can bundle the whole thing (client scripts, server scripts, and remote events), into a single folder, that is then put into ReplicatedStorage. Makes it very easy for people to include into their games, and is also a way of organizing code I quite like

7 Likes

0/10 very bad resource. The objects aren’t aligned with the mouse hence 0/10.

hey, not sure if you are using drag detectors for this but if you are trying to align the object with the mouse you should use align position

this stopped working for me. didn’t do anything to the scripts, but now the UI is just always on my screen and I can’t pick anything up

not sure what happened lol

yooo that’s me! I’m famous now guys

Option F: “I thought I was going to see an NPC get bodied”

I think if whatever you’re grabbing retained it’s orientation relative to camera, it would be more useful (sort of like Lumber Tycoon 2.) still cool tho


thanks :smiley:

4 Likes


:broken_heart:

i actually did add this in my newer version of it that i used for my game, but i won’t be updating this resource with anything since its kind of sucky

share the output logs pretty please

well uh i give your life a 0/10because uhh uh cries

1 Like

this is pretty cool. reminds me of source games like hl2 where you can pick stuff up

1 Like