(UNSOLVED PLEASE HELP) How would I make this Remote Event safer?

So, I’m basically making when you mine a Rock Coins will make the effect which PSX Does, The Problem I’m having currently is that they appear only on the Client.

And when the Player collects it it fires a Remote event and give the Player the Coins, Well this can be exploited Very easily right? Well That’s why I’m trying to make it safe so exploiters can’t just fire the Remote event and get infinite Coins

Local Script (Rock Mining)

Pickaxe.Activated:Connect(function()

	if Mouse.Target then
		if (Mouse.Target.Name == "GoldOre" or Mouse.Target.Name == "EnchantedGoldOre") then
			if Mouse.Target:FindFirstChild("MaxHealth") and Mouse.Target:FindFirstChild("Health") and Player.StatsFolder.Level.Value >= Mouse.Target.Level.Value and (Mouse.Target.Position - Player.Character.HumanoidRootPart.Position).Magnitude <= 20 then


				Player.PlayerGui.MainGui.OreFrame.Visible = true
				PickaxeAnimation:Play()
				Player.PlayerGui.MainGui.OreFrame.OreHealthlabel.Text = Mouse.Target.Health.Value .. "/" .. Mouse.Target.MaxHealth.Value

				Mouse.Target.GoldUI.Frame.StatusFrame.Size = UDim2.new(Mouse.Target.Health.Value / Mouse.Target.MaxHealth.Value,0,1,0)
				Mouse.Target.GoldUI.Frame.HealthDisplayLabel.Text = Mouse.Target.Health.Value .. "/" .. Mouse.Target.MaxHealth.Value
				Player.PlayerGui.MainGui.OreFrame.StatusFrame:TweenSize(UDim2.new(Mouse.Target.Health.Value / Mouse.Target.MaxHealth.Value, 0,1,0))
				if Mouse.Target.Health.Value == 0 then
					GoldDropsModule.DropGold("GoldDrop", Mouse.Target.CFrame, math.random(6,8), Mouse.Target)
					Player.PlayerGui.MainGui.OreFrame.Visible = false
				end
				
				Pickaxe.PickaxeEvent:FireServer(Mouse.Target)
				
				
			end
		end
	end
end)




Module Script

local module = {}

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Debris = game:GetService("Debris")


local ReplicatedStorageGoldDrop = ReplicatedStorage:WaitForChild("GoldDrops")
local GoldDrops = game.Workspace.Map.GoldDrops

local Player = game.Players.LocalPlayer



function module.DropGold(Currency,OriginCFrame,Amount, Target)



	for i = 0, Amount do
		local GoldDrop = ReplicatedStorageGoldDrop:FindFirstChild(Currency):Clone()
		GoldDrop.Name = "GoldDrop"
		GoldDrop.CFrame = OriginCFrame
		GoldDrop.Parent = GoldDrops


		local RandomX = {math.random(-10,-5), math.random(5,10)}
		local RandomZ = {math.random(-10,-5), math.random(5,10)}

		local Velocity = Vector3.new(RandomX[math.random(1,2)], 120, RandomZ[math.random(1,2)])

		GoldDrop.AssemblyLinearVelocity = Velocity 
	end
end



RunService.RenderStepped:Connect(function()
	local Character = Player.Character or Player.CharacterAdded:Wait()

	if Character then
		for _, Gold in pairs(GoldDrops:GetChildren())  do
			if (Gold.Position - Character.HumanoidRootPart.Position).Magnitude <= 8 then
				Gold.Anchored = true
				Gold.CanCollide = false
				Gold.CFrame = Gold.CFrame:Lerp(Character.HumanoidRootPart.CFrame, .6)

				if (Gold.Position -  Character.HumanoidRootPart.Position).Magnitude <= 1 then

					coroutine.wrap(function()
						local GoldTween = game.TweenService:Create(Gold.BillboardGui, TweenInfo.new(.3), {Size = UDim2.fromScale(0,0)}):Play()

						task.wait(.3)
						Gold:Destroy()
                              RemotesEvent.Coins:FireServer()
					end)()
				end
			end
		end
	end
end)

return module

**Server (Gives Coins)**
```lua
RemotesEvent.Coins.OnServerEvent:Connect(function(Player)
Player.StatsFolder.Coins.Value += 2
end)
2 Likes

spawning and damaging rocks on the server side shoud make this secure

2 Likes

Yeah that’s the system currently
But what about exploiters can keep firing the Remote event that they collected the Coins from it meaning that they will get infinite Coins?

1 Like

Rather than allow the client to change the rock health, or directly trigger an event giving coins, have the client interect with the system by firing an event to deal damage to the rock. On the server, calcate the health of the rock, and when it reaches 0, give that player coins.

2 Likes

I’m making the orbs like PSX on the Client so this wouldn’t work.
I’m not trying to give them the Coins automatically they have to collect orbs which appear locally.

1 Like

I am that’s not the problem as I’ve said The players have to collect orbs which appear only on their Screen (Client)

1 Like

If you want something to happen only on the client, just setup a localscript which fires a function when the server fires an event to the client. Alternatively, you could be like PSX where the orbs show up server side, but can only be picked up by a specific player.

1 Like

PSX Orbs show on the Client, there is 100% another way to make the remote event safe.

1 Like

for your orbs issue,
Create A Value from the server, when the Rock is destroyed.
For example -

[SERVER SIDED SCRIPT]

if Rock.Health <= 0 then  -- The rock has no health left
   OrbCreateRemove:FireClient(PlayerWhoBrokeTheRock)
end

Then from the client, you wait until the value exists,
suppose for example,

[CLIENT SIDED SCRIPT]

ValuesFolder.ChildAdded:Connect(function(ORB_CREATE_REQUEST)
-- We got a request to create orbs from the SEVER
end)

now when the player COLLECTS the orbs from the client,
On the Coin Giving Remote event you can do

[SERVER SIDED SCRIPT]

CoinEvent.OnServerEvent:Connect(function(Player,OrbRequest)
    if OrbRequest ~=nil then 
   -- This means that The ORBS Should exist and the player isint exploting
    end
end)

(I had made something like this for my game before, so i know this is possible.)

1 Like

Aren’t you firing the Remote event? why are you using ChildAdded?

1 Like

fire the event when the child got added

1 Like

OOPS,
my bad, dont fire a remote, i meant to add a Value inside a Folder which i took as ValuesFolder,
so in the Server Sided Script

it should be something like

if Rock.Health <= 0 then  -- The rock has no health left
   local NewValue=Instance.new('IntValue') -- Create a value to store
   NewValue.Parent = ValuesFolder -- the Folder where we will detect orb creating requests
   NewValue.Name = PlayerWhoBroke.Name -- So we know that who should get orbs
   NewValue.Value = OrbRewardAmount -- the reward amount in coins 
end

and in the client script, before creating orbs you can just check

if orbvalue.Name == Player.Name then -- The orb is made for us
    -- Create orb
end

and again, on the server you can check if the orb belongs to the player

if OrbValue ~= nil then -- Not Exploiting
    if OrbValue.Name==Player.Name then -- The orb was collected by the player it was made for
        -- reward the player with coins
        Player.coins.Value += OrbValue.Value
    end
end

(sorry if this is confusing, im bad at explaining)

1 Like

I’ll try it.

2 Likes

What’s the ValueFolder? this is really confusing

Does anyone know what else could I do to make it safe?

you can create any folder in workspace, which can act as the “ValueFolder”

in the folder we will create IntValues using the ServerSidedScript To Store
So that we can create orbs on the client safely.

This way is really confusing and I don’t think that it will work is there any other way to do it?

there might be,
but im not sure.

Thats the only way i know and thats the way i did it for my game.

Oh, well I think there is a better way.
I guess I’ll waiting for someone who is advanced in scripting to help.

So, does anyone know how do I make it safer easily?