Hello, this might be kind of confusing but how do i make the keys or the item stay in that place and the key/item can get by every player one by one without disappearing the keys/item and also the maximum of the key/item of each player is one.
When they touch the key clone it and give it to them. Then next time they touch it make sure to check if they already have one.
Example:
local canTouch = true
myKey.Touched:Connect(function(touchPart)
if(not(canTouch))then return end --They can't touch it right now
canTouch = false --Mark they can't touch it
local humanoid = touchPart.Parent:FindFirstChildWhichIsA("Humanoid")
if(humanoid)then
--Is a player/npc
local char = humanoid.Parent
local player = game:GetService("Players"):GetPlayerFromCharacter(char)
--Do they already have the key?
local hasKey = false
if(char:FindFirstChild("myKey"))then
--They already have it
hasKey = true
else
if(player)then
if(player.Backpack:FindFirstChild("myKey"))then
--They have it in their backpack
hasKey = true
end
end
end
--If they Don't have the key give them one.
if(not(hasKey))then
local newKey = myKey:Clone()
newKey.Parent = player.Backpack --put the key in their backpack
end
end
canTouch = true
end)
Simply just make it visible on client do checks to make sure they already havent claimed it and give them it and destroy it after wards the check is fired on server to give them the item.