I wanna make the duping prevention code, but I even don't know how does duping works. My shop system is like this:
[client]
local isSuccess = buyItemFunc:InvokeServer(data.ID)
[Server]
`buyItemFunc.OnServerInvoke = function(player, itemID)
if not player:GetAttribute("InShop") then
warn(player.Name .. " Unusual Activity Detection")
return false
end
local character = player.Character
if not character or (character.HumanoidRootPart.Position - TELEPORT_POS).Magnitude > MAX_DISTANCE then
warn(player.Name .. " Unusual Activity Detection")
return false
end
local leaderstats = player:FindFirstChild("leaderstats")
local userCoins = leaderstats and leaderstats:FindFirstChild("Coins 🪙")
if not userCoins then return false end
local targetItemData = nil
for _, item in ipairs(shopItems.List) do
if item.ID == itemID then
targetItemData = item
break
end
end
if targetItemData and userCoins.Value >= targetItemData.Price then
local toolTemplate = ServerStorage:WaitForChild("Items"):FindFirstChild(itemID)
if toolTemplate then
userCoins.Value -= targetItemData.Price
toolTemplate:Clone().Parent = player.Backpack
toolTemplate:Clone().Parent = player.StarterGear
return true
end
end
return false
end`