Help with getting items into inventory

Hello everyone!

I am currently creating a diner for my group. All of the food models have been made and I want it when a player clicks/taps on the item it will appear in their inventory, and they can hold it. I have tried to find YouTube videos and tutorials on how to do this but so far I have had no luck. Please reach out if you can help!

-ZEELZEKE

local clickDetector = script.Parent.ClickDetector

function onClick(player)
	local clone = game:GetService("ReplicatedStorage").Apple:Clone()
	clone.Parent = player.Backpack
end

clickDetector.MouseClick:Connect(onClick)

Fixed the script. The script is by tonmairoblox change “Apple” to the item and have a tool in replicated storage

local Tool = script.Parent

Tool.Equipped:Connect(function()
	script.Equip.Disabled = false
end)

Tool.Unequipped:Connect(function()
	script.Equip.Disabled = true
end) 

Needs to be a child of the tool in replicated storage as well.

and

local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local Debounce = true

UIS.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.Z and Debounce == true then
		Debounce = false
		script.RemoteEvent:FireServer(plr)
		wait(3)
		Debounce = true
	end
end)

as a child of the script in the tool

1 Like