How do I prevent this exploit?

for i,v in pairs(game:GetService("Workspace").Coins:GetDescendants()) do
    if v:IsA("MeshPart") then
        v.CFrame = game.Players.LocalPlayer.Character.HumanoidRootPart.CFrame    
    end
end

What is a good way to prevent this from happening? My touched connection is in server.

1 Like

From what I heard, Touch connection is actually on client.

Check the distance between the player and the coin on the server

2 Likes

You can do server-side checks to make sure the player is actually near the coin on the server’s end using .magnitude, for example:

local mag = (character.HumanoidRootPart.Position - coin.Position).magnitude

if mag < 5 then
    -- give player the coin
end

ty

You probably shouldn’t kick the player because legitimate players with a bad connection might get falsely kicked. Just don’t collect the coin if the player isn’t near it.