Please excuse me if this isn’t the correct place, or if I’ve forgotten to include something! This is my first post!
What do you want to achieve?
I am trying to create a simple tree chopping system. I am unsure of how to decrement the tree’s “HP” while the player is interacting with the proximity prompt, and their axe has hit the tree.
What is the issue? Include screenshots / videos if possible!
Screen Recording 2021-01-13 at 5.47.23 PM
What solutions have you tried so far?
I am currently using a local script inside of
StarterPlayerScripts to handle the ProximityPrompt’s triggered and untriggered events. I then have a remote event inside of
ReplicatedStorage which is handled by a regular script inside of
ServerScriptService. This script to handle the actual tree damaging is below. As you can imagine, it’s a mess and doesn’t work.
if player.Character then
local axeInformation = findAxeFromCharacter(player.Character);
local axe = player.Character:FindFirstChild(axeInformation.Name);
local debounce = false;
local tree = partTouched.Parent;
local treeInformation = treeInformationHandler.getTreeInformation(tree.Name);
if treeInformation and not debounce then
debounce = true;
debounce = false;
How would any of you go about creating a system like this? I think my biggest confusion is not knowing when to handle something on the client/server and how to handle it.
I believe you should listen for these events on server-sided, NOT client-sided. That may be the issue.
Thank you for responding! I went ahead and tried that approach. I’m now facing the issue of the animation not looping. I was originally basing the damage function on when the axe makes contact with the tree via a touched function, but if the animation isn’t looping then it only hits the tree once. Is there a better approach to this? I’ve included a video of the animation problem as-well!
These functions are called when the ProximityPrompt is triggered and untriggered. (dis-triggered?)
local onTriggered = function(player)
print(player.Name.." began chopping down a tree!");
if player.Character then
local animation = Instance.new("Animation");
animation.AnimationId = "rbxassetid://"..6222766141;
animation.Name = "swingAnim";
local swingAnim = player.Character:FindFirstChildWhichIsA("Humanoid"):LoadAnimation(animation);
loadedAnimationsTable["swingAnim"] = swingAnim;
swingAnim.Looped = true;
--player.Character.HumanoidRootPart.Anchored = true;
local onTriggerEnded = function(player)
print(player.Name.." stopped chopping down a tree!");
local swingAnim = loadedAnimationsTable["swingAnim"];
--player.Character.HumanoidRootPart.Anchored = false;
Humanoid:LoadAnimation() is now deprecated, use Animator, a child of the humanoid, to Animator:LoadAnimation() instead.
Thank you for pointing that out! I’ve went ahead and made those changes but the new problem of the animation not looping, and subsequently not being able to figure out a way to handle the actual axe-has-touched-a-tree part is still what I’m trying to figure out.
Like I said previously, I’m unsure if there’s a better approach to figuring out when the axe has touched a tree besides a touched event.