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)