local CollectionService = game:GetService("CollectionService")
local TaggedParts = CollectionService:GetTagged("Items")
local Debounce = false
local UserInputService = game:GetService("UserInputService")
for _,TaggedPart in pairs(CollectionService:GetTagged("Items")) do
TaggedPart.Touched:Connect(function(Hit)
if Hit.ClassName == "MeshPart" then if Debounce == false then if TaggedPart.Held.Value == false then
Debounce = true
game.ReplicatedStorage.Functions.Pickup:InvokeServer(TaggedPart,Hit)
test = TaggedPart
end
end
end
end)
end
local function onInputBegan(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
if input.KeyCode == Enum.KeyCode.G then
print(test.Name)
game.ReplicatedStorage.Functions.Pickup:InvokeServer(TaggedPart,Hit)
end
end
end
I know I cant use TaggedPart or hit in this input function but how can I replicate it?

1 comment
Use the return function