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

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.

4 Likes