please help me
player = game.Players.LocalPlayer mouse = player:GetMouse() itemnear = nil while true do pcall(function() local modelRoots = game.Workspace.Items:GetChildren() for i = 1,#modelRoots do local playerRoot = script.Parent.HumanoidRootPart local distance = (playerRoot.Position - modelRoots[i].Position).Magnitude local radius = 10 if(distance <= radius) then print("Your close to "..modelRoots[i].Name) itemnear = modelRoots[i] else itemnear = nil end end end) pcall(function() mouse.KeyDown:Connect(function(key) if key == "f" then if itemnear then print("Picked Up "..itemnear.Name) game.ReplicatedStorage.ItemSystem.PickUpEvent:FireServer(itemnear) itemnear:Destroy() end end end) end) wait(0.5) end
also the server script
game.ReplicatedStorage.ItemSystem.PickUpEvent.OnServerEvent:Connect(function(plr,item) local clone = game.ReplicatedStorage.ItemSystem:FindFirstChild(item.Name):Clone() clone.Parent = plr.Character return end)
I am not that smart but maybe add return at the end?