What I want is when this remote event is fired, the given "orb"is cloned and parented to the player’s backpack once. However what happens is that when this remote event is fired, it constantly adds the cloned “orb” to the player’s backpack! Is there anyway to fix this – I tried adding a debounce where it only parents the cloned “orb” if the cloned orb isn’t in the player’s backpack but it doesn’t seem to be working. Thanks!
OrbGiveEvent.OnServerEvent:Connect(function(_, Orb)
local toolClone = Orb:Clone()
if table.find(Player.Backpack:GetChildren(), toolClone.Name) == nil then
toolClone.Parent = _:FindFirstChildOfClass("Backpack")
end
end)
orbGiveEvent.OnServerEvent:Connect(function(player, orb)
if not player.Backpack:FindFirstChild('Orb') then
orb:Clone().Parent = player.Backpack
end
end)
You shouldn’t need a loop. Try this if the orb name can vary:
orbGiveEvent.OnServerEvent:Connect(function(player, orb)
if not player.Backpack:FindFirstChild(orb.Name) then
orb:Clone().Parent = player.Backpack
end
end)