Welcome to the Forums!
Join thousands of other Roblox members with a free account.
Create Forum Account

how to create a tool that breaks parts like lumber tycoon 2

  • This website was created by Roblox members to replace the official forums (because Roblox shut them down) Join us if you like Roblox!
Status
Not open for further replies.

Shavow

New Member
Reputation: 0 / 0 / 0
Apr 11, 2021
7
0
1
Roblox
versuiv
hi everyone, I'm working on a simulator right now based on lumber tycoon 2, and I want to make a tool that breaks trees in half but I'm not sure how to make a tool that breaks parts, and the only thing I've found online was a tool destroying parts, so if someone can at least give me an idea of how to write that script or help me create a script for a tool, that would be awesome! Thank you very much
 

N00bRobloxian09

New Member
Reputation: 0 / 0 / 0
Feb 7, 2018
24
8
3
I would add a localscript in my tool and every time u chop, fire a remote, idk something like this:

Lua:
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:

Lua:
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

1618997131284.png

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
 
  • Like
Reactions: HolyHan

thecatmeow1223

Active Member
Reputation: 1 / 0 / 0
Oct 24, 2020
596
9
160
43
an unknown place in the world
youtube.com
Roblox
TheMeowingNoob
I would add a localscript in my tool and every time u chop, fire a remote, idk something like this:

Lua:
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:

Lua:
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
The problem with this is that when you equip the tool, it will chop the tree. You want to chop the tree when the player clicks. Where is the break tree function too?
 

thecatmeow1223

Active Member
Reputation: 1 / 0 / 0
Oct 24, 2020
596
9
160
43
an unknown place in the world
youtube.com
Roblox
TheMeowingNoob
and I want to make a tool that breaks trees in half but I'm not sure how to make a tool that breaks parts, and the only thing I've found online was a tool destroying parts, so if someone can at least give me an idea of how to write that script or help me create a script for a tool, that would be
This person stated that the only thing they have found is a tool he destroys parts so they asked here. I thought maybe if they were to follow that tutorial but add unanchor then it would give it the phisics that they were looking for. If they want, they can unanchor the part, wait some time and destroy it.
 

N00bRobloxian09

New Member
Reputation: 0 / 0 / 0
Feb 7, 2018
24
8
3
I would add a localscript in my tool and every time u chop, fire a remote, idk something like this:

Lua:
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:

Lua:
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
The problem with this is that when you equip the tool, it will chop the tree. You want to chop the tree when the player clicks. Where is the break tree function too?

No? Tool.Equipped is when you equip,
Tool.Activated is when you left click.
(From wiki: "Tools will normally trigger the Tool.Activated event when the player releases the left mouse button, while the tool is equipped."), so yeah. Also I never said I'm gonna write the whole script, OP asked only for an idea on how it could work. The chopping thing can be done using raycast, or if it's a simple part then by getting a position of the mouse click and then divide the part in two as said.

It isnt hard to google "cutting parts in half" site:devforum.roblox.com
 

thecatmeow1223

Active Member
Reputation: 1 / 0 / 0
Oct 24, 2020
596
9
160
43
an unknown place in the world
youtube.com
Roblox
TheMeowingNoob
I would add a localscript in my tool and every time u chop, fire a remote, idk something like this:

Lua:
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:

Lua:
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
The problem with this is that when you equip the tool, it will chop the tree. You want to chop the tree when the player clicks. Where is the break tree function too?

No? Tool.Equipped is when you equip,
Tool.Activated is when you left click.
(From wiki: "Tools will normally trigger the Tool.Activated event when the player releases the left mouse button, while the tool is equipped."), so yeah. Also I never said I'm gonna write the whole script, OP asked only for an idea on how it could work. The chopping thing can be done using raycast, or if it's a simple part then by getting a position of the mouse click and then divide the part in two as said.

It isnt hard to google "cutting parts in half" site:devforum.roblox.com
Don't bovver helping if your just gonna give them half of it, give them the whole script/
 
Status
Not open for further replies.