When you equip/unequip the tool a weapon that is jointed to your right arm appears with equip/unequip/idle animations playing.
when you click (activate) the tool, a swing animation plays. (2 swing anims total) The joint on the weapon attached to your right arm is for more movement in the swing/idle/unequip/equip anims.
The weapon will have a damaging hitbox that will just simply be a single rectangular part that is welded and in the same position as the blade of the weapon. The hitbox will do damage from the start of the swing to the end of the swing.
I’ve made all the animations and just need to know how to do all of the above.
Use the Tool methods such as .Activated and .Equipped and play them through an Animator in the localPlayers Humanoid. Use .Touched for the Hitbox, .Touched in its first param returns which part was touched and you can use that to find the target Player’s Humanoid and apply damage to it. Make sure you implement a debounce to avoid excessive amounts of damage being appied.
@Ripxff was correct, but I have a feeling you shouldnt use .touched.
Instead, you can use Block casts to do the work. Block casts can use params, and they are maybe easier to do.
How I would do it is add a boolean, once a tool is activated, set the boolean to true, then wait a couple seconds, then set it to false
After you set the boolean to true, you can utilize functions and loops to do continuous blockcasts while the boolean is true.
For example:
function active_hitbox_()
while boolean == true do
task.wait()
-- blockcast code
end
end
tool.Activated:Connect(function()
boolean = true
active_hitbox_()
task.wait(1)
boolean = false
end
I was just saying its simple to use .Touched since whatever hes using it for isnt going to be throwing a part at 9999 speed and expecting it to detect it. I havent played around with the new casts yet though and Ill have to give them a try
The way Roblox automatically “welds” a Tool to the hand is by making a part named “Handle” and properly welding it to the sword under a Tool object, similar to how you’d be making the hitbox. Make sure its not Collidable
You can fix this by turning “RequiresHandle” off. As for now, I am too lazy to make an example, ill just add a piece of code i made a while ago.
local tool_weld_target = "Right Arm"
local weld_target = tool.Handle
local gun_weld = nil
tool.Equipped:Connect(function()
if character:FindFirstChild(tool_weld_target) then
local weld_target = character:WaitForChild(tool_weld_target)
local weld = Instance.new("Motor6D")
weld.Parent = weld_target
weld.Part0 = weld_target
weld.Part1 = tool_primary
gun_weld = weld
end
end
But as the post above me said, roblox automates this process. By making a part called “Handle” and welding everything to that part, it will automatically create a joint.
dont I need to make the position of the sword the same as where it was when I was making the animations for it in order for it to move by itself as well? If so, how do I do that?