How would I make a cook burgers item grabbing like mehanic?

I’m trying to make a mechanic where you can grab and pick up food, I’m just not sure where to start. I’m also not sure how to change the position of the food where I want. Thanks any suggestions help!

1 Like

you can using a ClickDetector for grabbing, like this

local Burger = workspace.Burger
local ClickDetector = script.Parent

ClickDetector.MouseClick:Connect(function()
    Burger:Destroy()
    local BurgerTool = game.ServerStorage:WaitForChild("Burgers")
    BurgerTool:Clone().Parent = game.Players:WaitForChild("Backpack",60) -- Wait Until Backpack Are Successfully Processed
end)
1 Like

I’m not trying to make it go to the backpack I’m trying to grab it and move it with your cursor.

1 Like

Hi, to make a simple dragging system you can do :

local MS = game.Players.LocalPlayer:GetMouse()
local Head = game.Players.LocalPlayer.Character:WaitForChild('Head')
local Part
local Distance = 0

local function CanDrag(Part)
	if Part and not Part.Anchored and (Head.Position - Part.Position).Magnitude < 10 then return Part end
end

MS.Button1Down:Connect(function()
	if CanDrag(MS.Target) then
		Part = MS.Target
		Distance = (Head.Position - Part.Position).Magnitude
		MS.TargetFilter = Part
		Part.Anchored = true
		Part.CanCollide = false
	end
end)

MS.Button1Up:Connect(function()
	if Part then
		Part.Anchored = false
		Part.CanCollide = true
		Part = nil
		Distance = 0
		MS.TargetFilter = nil
	end
end)

game:GetService('RunService').RenderStepped:Connect(function()
	if Part then
		local Goal = Head.Position + (MS.UnitRay.Direction * Distance)
		Part.Position = Part.Position:Lerp(Goal,.2)
	end
end)

Also, as for replicating it on the server, you can probably use remote events.

1 Like