local miningevent = game:GetService("ReplicatedStorage"):WaitForChild("Mining")
local oreevent = game:GetService("ReplicatedStorage"):WaitForChild("GetOre")
local hv = script.Parent
local pickaxestrength = 1
miningevent.OnServerEvent:Connect(function()
if not hv then return end -- stop code if hv got destroyed
hv.Value -= pickaxestrength
oreevent:FireClient()
print(hv.Value)
end)
hv:GetPropertyChangedSignal("Value"):Connect(function()
if hv.Value == 0 or hv.Value<0 then
print("destroyed")
script.Parent.Parent:Destroy()
end
end)
there is an error about the client event, it says that an argument is missing but i can’t understand what’s missing, the event is used for another script:
local sss = script.Parent
local pd = sss.PlayerData
local data = pd.Data
local manager = require(pd.Manager)
local rs = game:GetService("ReplicatedStorage")
local oreevent = rs.GetOre
local oremultiplier = math.random(1.1, 2)
local pickstrength = require(pd.Pickaxe)
local wpick = pickstrength.woodpick
local function addore(player: Player)
manager.AdjustOres(player, wpick*oremultiplier)
end
oreevent.OnClientEvent:Connect(addore)
When using FireClient you need a player to fire the remote to, you can get the player who fired it in OnServerEvent by using OnServerEvent:Connect(function(plr)
and use FireClient(player) to fire it to the player
local miningevent = game:GetService("ReplicatedStorage"):WaitForChild("Mining")
local oreevent = game:GetService("ReplicatedStorage"):WaitForChild("GetOre")
local hv = script.Parent
local pickaxestrength = 1
miningevent.OnServerEvent:Connect(function(player)
if not hv then return end -- stop code if hv got destroyed
hv.Value -= pickaxestrength
oreevent:FireClient(player)
print(hv.Value)
end)
hv:GetPropertyChangedSignal("Value"):Connect(function()
if hv.Value == 0 or hv.Value<0 then
print("destroyed")
script.Parent.Parent:Destroy()
end
end)
Client Script
local player = game.Players.LocalPlayer
local sss = script.Parent
local pd = sss.PlayerData
local data = pd.Data
local manager = require(pd.Manager)
local rs = game:GetService("ReplicatedStorage")
local oreevent = rs.GetOre
local oremultiplier = math.random(1.1, 2)
local pickstrength = require(pd.Pickaxe)
local wpick = pickstrength.woodpick
local function addore()
manager.AdjustOres(player, wpick*oremultiplier)
end
oreevent.OnClientEvent:Connect(addore)
local player = game.Players.LocalPlayer
local sss = script.Parent
local pd = sss.PlayerData
local data = pd.Data
local manager = require(pd.Manager)
local rs = game:GetService("ReplicatedStorage")
local oreevent = rs.GetOre
local oremultiplier = math.random(1.1, 2)
local pickstrength = require(pd.Pickaxe)
local wpick = pickstrength.woodpick
local function addore()
print("fired ")
manager.AdjustOres(player, wpick*oremultiplier)
end
oreevent.OnClientEvent:Connect(addore)
How exactly did it fix the issue? local function addore(player)? The function is called by OnClientEvent and there will be no parameters when calling the function