Need help with my hitbox script

I have been trying to fix this for 3 days now and it is making no sense. I have a hixbox put on each player at the start of the game. The hitbox has a script in it that can be run by setting the DamageIntake Bool value within the script to true which is detected by by a changed event.
I have also put a string value within the script that is called CurrentPlayer and has the name of the current model that the hitbox is inside. For some reason even though the currentPlayer value is set to the correct player(I checked them in a running 2 player game) , one player is able to hit the other but the second player cannot hit the first. I have printed the player names at the start of the script to ensure it is the right player but it still detects the wrong player when I say

game.Workspace:FindFirstChild(script.CurrentPlayer.Value).Humanoid.Health -= script.DamageAmount.Value

This makes no sense as it seems like the string value somehow has 2 values at once. I have check and changed the code over the last 3 days as much as possible with no luck. Someone save me please.

Here is the full code : `

--Welds the hitbox to the player
while true do
	if script.Parent.Parent.Parent:FindFirstChild("Humanoid") then
		script.CurrentPlayer.Value = script.Parent.Parent.Parent.Name
		local rootPart = game.Workspace:FindFirstChild(script.CurrentPlayer.Value).HumanoidRootPart

		local weld ="Weld",rootPart)
		weld.Part0 = rootPart
		weld.part1 = script.Parent
		weld.C1 *=,.5,0)


local IFramesTime = 0.1

--Character features
local hitBox = script.Parent
local damageIntake = script.hit
local event = game.ReplicatedStorage.RemoteEvents.BDD

--Character action states
local IsBlocking = false
local blockFrames = 0

--Asks client for character actions
	print(script.Parent.Parent.Parent.Name.." script running")
	--Ensure the damage change is the player getting hit and not the IFrames vanishing
	if change == true then
	damageIntake.Value = false

--Client returns values and the attack is run
event.OnServerInvoke = function(plr,value,blockTime,defenenceType)

	if defenenceType == "Blocking" then
		blockFrames = blockTime
		IsBlocking = value

	if IsBlocking == false then

		game.Workspace:FindFirstChild(script.CurrentPlayer.Value).Humanoid.Health -= script.DamageAmount.Value
		print(game.Workspace:FindFirstChild(script.CurrentPlayer.Value).Name.."got hit")
		if script.Ragdoll.Value == true then
			local ragdollScript  = require(game.ServerScriptService.ServerScripts.Ragdoll)
			script.Ragdoll.Value = false
			script.RagdollTime.Value = 0
		if script.KnockBackPower.Value > 0 then
			local velocity ="BodyVelocity",game.Workspace:FindFirstChild(script.CurrentPlayer.Value).HumanoidRootPart)
			velocity.MaxForce =,math.huge,math.huge)
			velocity.Velocity = game.Workspace:FindFirstChild(script.PlayerWhoHit.Value).HumanoidRootPart.CFrame.LookVector * script.KnockBackPower.Value

1 Like

Here is a studio layout and the script that puts the hitboxes into the character as they join:

1 Like


If the hitbox is inserted directly into the character then there is 1 too many Parent properties.

script.CurrentPlayer.Value = script.Parent.Parent.Name

Second, there are a ton of organizational issues in your code, which is likely why it is so hard to debug. I would recommend creating more variables, as you set a lot of things equal to the same thing over and over again.

I will keep playing around with the script to see if I can get the system to give me the same issue, however, I just wanted to make sure that the hitbox is getting put in the right spot before I continue.

Thanks a lot! I will try organise it more but I still really need help with this problem . Thanks for taking time out your day :pray:

1 Like

Right, so is the hitbox inserted directly into the character or somewhere else in the character?

It is in a folder within the character called Hitboxes, it is stored there along with output hitboxes for M1s and other moves.

1 Like

If you want to activate it without the need for a m1 system you can just set the damage number and set the hit bool value to true.

Also the reason it is so disorganised is because I thought if i used a string value for the character instead of getting a variable for it with script.Parent.Parent.Parent maybe it would work. So i do plan on changing that back if it has no effect on the issue.