Attack not doing damage?

  1. What do you want to achieve?
    I’m trying to make an attack in my game but…
  2. What is the issue?
    The attack only works when the player is moving. I’ve made an animation that resembles the player dropping a steamroller onto an enemy, but it doesn’t do damage correctly, should I make the hitbox part smaller?
  3. What solutions have you tried so far?
LocalHumPart = script.Parent:FindFirstChild("HumanoidRootPart")
Character = script.Parent
Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://5564889379"
Anim2 = Instance.new("Animation")
Anim2.AnimationId = "rbxassetid://5471633598"

function RoadRoller(player)
	if game.Players:GetPlayerFromCharacter(script.Parent) == player then
		local Barrage = 0
		wait(10)
					repeat			
						script.Parent:FindFirstChild("RoadRollerOBJ").HitBox.Touched:Connect(function(part)
							wait(0.2)
								Touch = false
								if part.Parent.Name == "Stand" then
									local newHumPart = part.Parent.Parent:FindFirstChild("HumanoidRootPart")
									newHum = part.Parent.Parent:FindFirstChild("Humanoid")
									if newHum then
										Touch = true
									else
										Touch = false
									end
								else
									local newHumPart = part.Parent:FindFirstChild("HumanoidRootPart")
									newHum = part.Parent:FindFirstChild("Humanoid")
									if newHum then
										Touch = true
									else
										Touch = false
									end	
								end
							end)
			Barrage = Barrage + 1
			print(Barrage)
						wait(0.1)
						if Touch == true then
							Touch = false
							newHum.Health = newHum.Health - 5.5
						end
			
		until Barrage == 60
	end
end



game.ReplicatedStorage.Folder.TheWorld2.RoadRoller.OnServerEvent:Connect(RoadRoller)

2 Likes

What variable did that come from? Also check the hitbox while testing to see if it’s actually there

  1. Make sure the Hitbox detection is firing.
  2. Ensure it is finding the children.
  3. Check the if statements

If you want to check where it is going wrong add prints in. e.g print(“Found Humanoid”)
or print(newHum)
that way you can check what is or isnt going right.

I would recommend doing this as a go to method of fault finding.

its detecting the humanoid, but only when the hitbox part is moving. I’m pretty sure this is a bug with Touched, however I wouldn’t know since I use this script for a lot of rush attacks and I’ve never had problems.

Instead of using newHum.Health = newHum.Health - 5.5 use
newHum:TakeDamage(5.5)

is the part anchored and being moved?
if so it wont register a .touched until the player moves, if they dont move theres a chance it will go right through them with no effects.

if this is the case the alternative is turning collision on then off again with each move.(Has to be quick otherwise it could effect the object)

.Touched fires when the game detects a part is touched by another object. This check only happens when either the part of the object move. If the player is stationary, and already touching the hitbox then you’re connecting the .Touched function after the .Touched event you’re looking for has happened.

Also, why are you connecting the steam roller function 60 times every time the RemoteEvent is fired?

The part is welded to the rest of the model

ok, but how is it being moved, is it a force or is the CFrame or position being changed with a script

The entire model is welded to the Players Left Leg, whenever you use shift lock or go into first person and rotate, the model moves as well, Touched only registers when the person is rotating.

perhaps that could be the issue then. if you attack and are no longer rotating, the touch might not register. and it will repeat 60 times whether it touches something or not

The reason I have set it to a loop of 60 is because I don’t want all the damage to be done at once, I want it to be “spread out” over the course of a couple of seconds, I have done this with my other rush scripts, they all worked out other than this one.

yes but when it repeats. its checking again for the hitbox.touched so if you are having issues with the hitbox the damage output will be effected. Hence why the having to rotate for the .touched to work is a issue.

(its inside the repeat)

Add a print onto the touched and print the touched every time, you will most likely see that it doesnt add up

Alright, I removed the Touch = false in the If Touch == true statement, it works fine now, thanks for the help