I dont really have code for click combat, (and i don’t want code from anyone, i wanna try to understand and learn how it works. Examples of code are fine tho!!!)
I dont really understand how click combat works, i want to make a game with click combat. An exclamation of how it works would be appreciated, thank you for your time
Hitboxes are invisible boxes that are used for detecting collisions more efficiently than parts with meshes, custom shapes, etc. They generally don’t have collisions of their own, mostly in the situation being described here.
There isn’t a hitbox Object, but instead you’d spawn a part covering the areas where you want collisions to be for said attack, and check the collisions there.
-- The UserInputService happenned
local Hitbox = Instance.new("Part")
Hitbox.Size = -- Whatever box sized hitbox you want
Hitbox.Shape = enum.Shape.Block -- just confirm its a block
Hitbox.Touched:Connect(function(hit)
local Check = hit.Parent:FindFirstChild("Humanoid") -- Check if it's a character
if Check then
Check:TakeDamage(100) -- Damage the humanoid
end)
end)
If you have questions about the code you can ask. (it can be a bit confusing)
Nope! You just have to make the size as big as you want! basically the bigger the numbers the bigger the chance of hitting the player : )
also remember that the size value is a tuple like this (0,0,0) and for better calculations you may want to make your hitbox ahve the same numbers such as (5,5,5)
Instead of putting them in the same function, you can separate them thru InputStarted, which can help with your variable organization. For this you could do:
UserInputService.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseButton1 and not Dbounce then
DBounce = true
punch1Track:Play()
wait(waitTIme)
DBounce = false
end
end)