(SOLVED)Hitbox isnt detecting anything

Hello!

I have a hitbox for my ability which for some reason doesn’t detect if a player touched it, I have placed print statements in my code but nothing worked. Thank you for helping!
(also the locals are necessary)

Code:

local TS = game:GetService("TweenService")
local fireing = false

local impactFrame = false
local hbActive = true
local hbDB = false
local fx = game.ReplicatedStorage.EffectsForMoves.SliceStuff:Clone()
fx.Parent = workspace.SliceFOlder
script.Parent.OnServerEvent:Connect(function(plr,pos)
	local hrp = plr.Character:WaitForChild("HumanoidRootPart")
	if plr:WaitForChild("Values").MoveActive.Value == false and plr:GetAttribute("Stunned") == false then
	if fireing == false then
		fireing = true
			local position = pos
			local re = game.ReplicatedStorage.EffectsForMoves.Reveal:Clone()
			re.Parent = workspace
			local blade = game.ReplicatedStorage.EffectsForMoves.Yes:Clone()
			local b2 = game.ReplicatedStorage.EffectsForMoves.SliceStuff:Clone()
			local Moon = game.ReplicatedStorage.EffectsForMoves.Moon:Clone()
			Moon.Parent = workspace
			hrp.Anchored = false
			re.CFrame = CFrame.new(Vector3.new(pos.X,1.5,pos.Z))
			wait(1.3)
			re:Destroy()
			blade.Parent = workspace
			blade.CFrame = CFrame.new(Vector3.new(pos.X,-15,pos.Z))
			TS:Create(blade, TweenInfo.new(0.35,Enum.EasingStyle.Quad, Enum.EasingDirection.In, 1, false, 0), {Position = Vector3.new(position.X, 4, position.Z)}):Play()
			wait(1.55)
			blade.Touched:Connect(function(hit)
				if hbActive == true then
					if game.Players:FindFirstChild(hit.Parent.Name) or hit.Parent.Name == "TestDummy" then
						hbActive = false
						print("PlayerFound")
						if hit.Parent.Name == plr.Name then
							print("Stop hitting yourself man!")
							return
							
						else

							local HitHum = hit.Parent:WaitForChild("Humanoid")



							if hit.Parent:FindFirstChild("Humanoid") then
								if impactFrame == false then
									impactFrame = true
									TS:Create(hit.Parent.HumanoidRootPart, TweenInfo.new(0.35,Enum.EasingStyle.Quad, Enum.EasingDirection.In, 1, false, 0), {Position = Vector3.new(hit.Parent.HumanoidRootPart.Position.X,50,hit.Parent.HumanoidRootPart.Position.Z)}):Play()
									TS:Create(hrp, TweenInfo.new(0.35,Enum.EasingStyle.Quad, Enum.EasingDirection.In, 1, false, 0), {Position = Vector3.new(hit.Parent.HumanoidRootPart.Position.X+2,50,hit.Parent.HumanoidRootPart.Position.Z+2)}):Play()
									
									game.ReplicatedStorage.Events.SecretSlash:FireClient()
									wait(0.13)
									wait(1.8)
									hit.Parent.Humanoid:TakeDamage(110)
									local pushForce = 40
									local vel = Instance.new("BodyVelocity", hit.Parent.HumanoidRootPart)
									vel.MaxForce = Vector3.new(1,1,1) * 1000000;
									vel.Parent = hit.Parent.HumanoidRootPart
									vel.Velocity = Vector3.new(1,1,1) * plr.Character:WaitForChild("HumanoidRootPart").CFrame.LookVector * pushForce
									vel.Name  =  "SmallMoveVel"
									game.Debris:addItem(vel,1)
				
						

								end
							end
						end
					end	
				end
			end)
			hrp.Anchored = false
		fireing = false
			plr:WaitForChild("Values").MoveActive.Value = false
			hbActive = true
			impactFrame = false
			fx:Destroy()
			hbDB = false
			b2:Destroy()
			blade:Destroy()
		end
	
	else
		return	
	end
end)
game.ReplicatedStorage.Events.SecretSlash.OnServerEvent:Connect(function()
	fx.A.First:Emit(1)
	wait(0.20)
	
	fx.A.Second:Emit(1)
	wait(0.10)

	fx.A.Third:Emit(1)
	wait(0.10)

	fx.A.Forth:Emit(1)
	wait(0.10)

	fx.A.Fifth:Emit(1)
	wait(0.10)

	fx.A.Sixth:Emit(1)
	wait(0.10)
	
	fx.A.Seventh:Emit(1)
	wait(0.10)

	fx.A.eight:Emit(1)
	wait(0.10)

	fx.A.nineth:Emit(1)
	wait(0.10)
	
	fx.A.tenth:Emit(1)
	fx.A["10a"]:Emit(1)
	wait(0.10)
	

	fx.A["eleventh"]:Emit(1)
	wait(0.10)
	
	fx.A.twelve:Emit(1)
	wait(0.10)

	fx.A.thirteen:Emit(1)
	wait(0.10)

	fx.A.fourteen:Emit(1)
	wait(0.10)
	
	fx.A["fifteen-a"]:Emit(1)
	fx.A["fiveteen"]:Emit(1)	
	wait(0.10)
	fx.A.sixteen:Emit(1)
	wait(0.10)
	fx.A.eighteen:Emit(1)
	wait(0.30)
	fx.A.First:Emit(1)
	
end)

I’m thinking this is because it is waiting for the Remote Event to be fired first. You can see that the line:

blade.Touched:Connect(function(hit)

Is inside the code:

script.Parent.OnServerEvent:Connect(function(plr, pos)

You need to make sure that the remote event is firing first.

2 Likes

I did this with another ability i made(Its the exact same code except for the events when the player touches it) and it works, just this one doesn’t, which is weird. And the event is how the ability is started, Its a server script that gets fired by a local script.

If your script really hasn’t changed from one that is working, then maybe the part doesn’t have CanTouch.

Or, maybe you have two scripts listening for the same touch event. I have seen that cause a problem.

Alright ill check, the CanTouch property is checked, so thats not the problem, and its the only script so thats not it either, but thank you though!

Then add print statements after every event or if then statement leading up to the touch event.

local TS = game:GetService("TweenService")
local fireing = false

local impactFrame = false
local hbActive = true
local hbDB = false
local fx = game.ReplicatedStorage.EffectsForMoves.SliceStuff:Clone()
fx.Parent = workspace.SliceFOlder
script.Parent.OnServerEvent:Connect(function(plr,pos)
	print("fx server event")
	local hrp = plr.Character:WaitForChild("HumanoidRootPart")
	if plr:WaitForChild("Values").MoveActive.Value == false and plr:GetAttribute("Stunned") == false then
		print("values found")
		if fireing == false then
			print("firieing false")
			fireing = true
			local position = pos
			local re = game.ReplicatedStorage.EffectsForMoves.Reveal:Clone()
			re.Parent = workspace
			local blade = game.ReplicatedStorage.EffectsForMoves.Yes:Clone()
			local b2 = game.ReplicatedStorage.EffectsForMoves.SliceStuff:Clone()
			local Moon = game.ReplicatedStorage.EffectsForMoves.Moon:Clone()
			Moon.Parent = workspace
			hrp.Anchored = false
			re.CFrame = CFrame.new(Vector3.new(pos.X,1.5,pos.Z))
			wait(1.3)
			re:Destroy()
			blade.Parent = workspace
			blade.CFrame = CFrame.new(Vector3.new(pos.X,-15,pos.Z))
			TS:Create(blade, TweenInfo.new(0.35,Enum.EasingStyle.Quad, Enum.EasingDirection.In, 1, false, 0), {Position = Vector3.new(position.X, 4, position.Z)}):Play()
			wait(1.55)
			blade.Touched:Connect(function(hit)
				print("blade touched")
				if hbActive == true then
					print("hbActive == true")
					if game.Players:FindFirstChild(hit.Parent.Name) or hit.Parent.Name == "TestDummy" then
						hbActive = false
						print("PlayerFound")
						if hit.Parent.Name == plr.Name then
							print("Stop hitting yourself man!")
							return

						else

							local HitHum = hit.Parent:WaitForChild("Humanoid")



							if hit.Parent:FindFirstChild("Humanoid") then
								if impactFrame == false then
									impactFrame = true
									TS:Create(hit.Parent.HumanoidRootPart, TweenInfo.new(0.35,Enum.EasingStyle.Quad, Enum.EasingDirection.In, 1, false, 0), {Position = Vector3.new(hit.Parent.HumanoidRootPart.Position.X,50,hit.Parent.HumanoidRootPart.Position.Z)}):Play()
									TS:Create(hrp, TweenInfo.new(0.35,Enum.EasingStyle.Quad, Enum.EasingDirection.In, 1, false, 0), {Position = Vector3.new(hit.Parent.HumanoidRootPart.Position.X+2,50,hit.Parent.HumanoidRootPart.Position.Z+2)}):Play()

									game.ReplicatedStorage.Events.SecretSlash:FireClient()
									wait(0.13)
									wait(1.8)
									hit.Parent.Humanoid:TakeDamage(110)
									local pushForce = 40
									local vel = Instance.new("BodyVelocity", hit.Parent.HumanoidRootPart)
									vel.MaxForce = Vector3.new(1,1,1) * 1000000;
									vel.Parent = hit.Parent.HumanoidRootPart
									vel.Velocity = Vector3.new(1,1,1) * plr.Character:WaitForChild("HumanoidRootPart").CFrame.LookVector * pushForce
									vel.Name  =  "SmallMoveVel"
									game.Debris:addItem(vel,1)



								end
							end
						end
					end	
				end
			end)
			hrp.Anchored = false
			fireing = false
			plr:WaitForChild("Values").MoveActive.Value = false
			hbActive = true
			impactFrame = false
			fx:Destroy()
			hbDB = false
			b2:Destroy()
			blade:Destroy()
		end

	else
		return	
	end
end)
game.ReplicatedStorage.Events.SecretSlash.OnServerEvent:Connect(function()
	fx.A.First:Emit(1)
	wait(0.20)

	fx.A.Second:Emit(1)
	wait(0.10)

	fx.A.Third:Emit(1)
	wait(0.10)

	fx.A.Forth:Emit(1)
	wait(0.10)

	fx.A.Fifth:Emit(1)
	wait(0.10)

	fx.A.Sixth:Emit(1)
	wait(0.10)

	fx.A.Seventh:Emit(1)
	wait(0.10)

	fx.A.eight:Emit(1)
	wait(0.10)

	fx.A.nineth:Emit(1)
	wait(0.10)

	fx.A.tenth:Emit(1)
	fx.A["10a"]:Emit(1)
	wait(0.10)


	fx.A["eleventh"]:Emit(1)
	wait(0.10)

	fx.A.twelve:Emit(1)
	wait(0.10)

	fx.A.thirteen:Emit(1)
	wait(0.10)

	fx.A.fourteen:Emit(1)
	wait(0.10)

	fx.A["fifteen-a"]:Emit(1)
	fx.A["fiveteen"]:Emit(1)	
	wait(0.10)
	fx.A.sixteen:Emit(1)
	wait(0.10)
	fx.A.eighteen:Emit(1)
	wait(0.30)
	fx.A.First:Emit(1)

end)

OR use breakpoints instead.

why people use print instead? breakpoints are easy to spot and remove.

Thank you, this was the solution, i just needed to add a wait statement lol

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.