I have a script that i tried to make so when you clicked the part and if nobody was set to the owner to that part you would be the owner of the part but if i have multiple items in the folder then it sets my username to all of the values to all of the other items that are in the Folder, how would i do so it only sets the value to the object i clicked on?
while true do
for _,v in pairs(Items:GetChildren()) do
mouse.Button1Down:connect(function()
if Player then
if v.Owner.Value ~= Player then
v.Owner.Value = Player
if v.Owner.Value == Player then
if mouse.Target == v.PrimaryPart and (Player.Character.Torso.Position).magnitude <= 5 then
Interact.Visible = true
print(v.Name)
elseif mouse.Target ~= v.PrimaryPart or (Player.Character.Torso.Position).magnitude > 5 then
Interact.Visible = false
end
end
end
end
end)
end
wait(1)
end
