I would add a localscript in my tool and every time u chop, fire a remote, idk something like this:
Code:
local playersMouse = game.Players.LocalPlayer:GetMouse()
script.Parent.Activated:Connect(function() --On tool activation (chop)
game.ReplicatedStorage.onChop:FireServer(mouse.Target, mouse.Hit, mouse.Target.Parent)
end)
Then create a remoteevent in replicatedstorage called onChop, then add a normal script in serverscriptservice, something like this:
Code:
local function chopTree(plr, target, hit, tree)
--check for hits, assign tree ownership to a player who hit it to prevent stealing
--then check is hits are bigger than the maximumhits and break the part in two by executing another function ->
if not tree.Configuration.hits.Value < tree.Configuration.hitsToBreak.Value then
breakTree(plr, target, hit, tree)
end
end
game.ReplicatedStorage.onChop.OnServerEvent:Connect(function(player, target, hit, treemodel)
chopTree(player, target, hit, treemmodel)
end)
I would add some configuration in the tree model aswell
View attachment 40190
hits = where are the player's chops stored
hitstobreak = amount of hits for the tree to break
isTree = if its a breakable tree
treeOwner = the player who chopped it first
also, be sure to add patch some vulns. because anyone on the server with exploits can fire this remoteevent. so add some cooldown (tool reload time, serverside check) or check if the player is near the tree, something like that. good luck bud