I currently have a system where ores get dropped when mining a stone, and i want to increase the players ore amount every time you pick one up, i was planning on doing this via a RemoteEvent. The problem is that the only way i could think of how to do this would be to fire an event to the server every time an ore is picked up, but exploiters could just spam that event to gain an infinite amount of ores. I’m unsure how i would fix this issue, and would appreciate some advice on what to do.
Heres the script that sends the remote:
local plr = game.Players.LocalPlayer local char = plr.Character or plr.CharacterAdded:Wait() local root = char:WaitForChild("HumanoidRootPart") local ts = game:GetService("TweenService") local rs = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService") local SoundService = game:GetService("SoundService") RunService.Heartbeat:Connect(function() for i, drop in pairs(workspace.Drops:GetChildren()) do if drop:IsA("Part") then local magnitude = (root.Position - drop.Position).Magnitude if magnitude <= 8 then drop.CFrame = drop.CFrame:Lerp(root.CFrame,0.2) local touching = game.Workspace:GetPartsInPart(drop) local playerInPart = false for i, v in pairs(touching) do if v.Parent.Name == plr.Name then playerInPart = true end end if playerInPart then SoundService:PlayLocalSound(workspace.Sounds.PickupSound) --rs.Events.OrePickedUpEvent:FireServer() drop:Destroy() end end end end end)