okay so i have this script that uses Number Values under a rock in workspace, Durability and Worth, i have this local script:
local tool = script.Parent
local range = 20
local hit = game.ReplicatedStorage.MiningRemotes.Hit
local function onActivated()
local mouse = game.Players.LocalPlayer:GetMouse()
local mouseTarget = mouse.Target
local playerPosition = game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character.HumanoidRootPart.Position
local targetPosition = mouseTarget and mouseTarget.Position
if mouseTarget and mouseTarget.Name == "Rock" and playerPosition and targetPosition and (playerPosition - targetPosition).Magnitude <= range then
local dur = mouseTarget.Durability.Value
local mon = mouseTarget.Worth.Value
hit:FireServer(dur, mon)
end
end
tool.Activated:Connect(onActivated)
and a server script:
local remote = game.ReplicatedStorage.MiningRemotes.Hit
remote.OnServerEvent:Connect(function(dur, mon)
print(mon)
print(dur)
end)
the durability prints fine (2) but the worth value does this:
OnServerEvents automatically take the player as the first argument, which means that dur is the player, mon is dur, and the actual mon is nil. Try replacing that line with instead:
local remote = game.ReplicatedStorage.MiningRemotes.Hit
remote.OnServerEvent:Connect(function(plr, dur, mon)
print(mon)
print(dur)
end)
local script:
local tool = script.Parent
local range = 20
local hit = game.ReplicatedStorage.MiningRemotes.Hit
local plr = game.Players.LocalPlayer
local function onActivated()
local mouse = game.Players.LocalPlayer:GetMouse()
local mouseTarget = mouse.Target
local playerPosition = game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character.HumanoidRootPart.Position
local targetPosition = mouseTarget and mouseTarget.Position
if mouseTarget and mouseTarget.Name == "Rock" and playerPosition and targetPosition and (playerPosition - targetPosition).Magnitude <= range then
local dur = mouseTarget.Durability.Value
local mon = mouseTarget.Worth.Value
hit:FireServer(plr, dur, mon)
end
end
tool.Activated:Connect(onActivated)
You only need the player for OnServerEvent, not FireServer. If you aren’t sure about RemoteEvents then check out the documentation
If the problem still persists then it might come from another script