I am trying to make a pickaxe to break blocks but the code isnt working inside the ore is a int Value and both scripts are in the tool, same with the remote event Error:Health is not a valid member of Player "Players.cjkizzy286" Ps in the local script its saying that the target is the right thing but in the server script its saying its the player. Local script:
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
mouse.Button1Down:Connect(function()
local target = mouse.Target
local gems = game.Workspace["Ore Generator"].Gems
local equipped = true
local debounce = false
local pickaxeDamage = 10
local pickaxeSpeed = 0.75
local ttm = gems.Parent.StoredGems:GetChildren()
if equipped == true and target:IsA("UnionOperation") then
for i,v in pairs(ttm) do
if v == target then
if debounce == false then
debounce = true
print(target)
script.Parent.Health:FireServer(target)
wait(pickaxeSpeed)
debounce = false
end
end
end
end
end)
Server Script:
script.Parent.Health.OnServerEvent:Connect(function(target)
print(target)
target.Health = target.Health - 10
end)
