Same Script but only one of it working

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    make the script working fully
  2. What is the issue? Include screenshots / videos if possible
    the heavy hitbox is not working(btw,it depend on which script loads first,if heavyhitbox script on top of light,then light hitbox script is not working)
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local tool = script.Parent
local light = tool:WaitForChild("Light")
local heavy = tool:WaitForChild("Heavy")

local touchable = false

tool.Equipped:Connect(function()
----LightAnims---
local Animator = tool.Parent:FindFirstChild("Humanoid"):FindFirstChild("Animator")
local LightOne = tool.Anims.LightOne
local LightTwo = tool.Anims.LightTwo
	local HeavyTwo = tool.Anims.HeavyTwo
task.wait() 
	local Ltrackone = Animator:LoadAnimation(LightOne)
	local Ltracktwo = Animator:LoadAnimation(LightTwo)
	local Htracktwo = Animator:LoadAnimation(HeavyTwo)
	Htracktwo.Priority = Enum.AnimationPriority.Action
repeat task.wait() until Ltrackone.length > 0
	local LightAnims = {Ltrackone,Ltracktwo}
	local HeavyAnims = {Htracktwo}
----LightAnims---
	light.OnServerEvent:Connect(function()
			local hitbox = game.ServerStorage.HeavyHitBox:Clone()
			hitbox.Parent = tool.Parent
			hitbox.CFrame = tool.Parent:FindFirstChild("HumanoidRootPart").CFrame:ToWorldSpace(CFrame.new(0,0,-3))
			LightAnims[math.random(1,2)]:Play()
			touchable = true
			hitbox.Touched:Connect(function(otherPart)
				if otherPart.Parent == tool.Parent then
					return
				end
					if touchable == true then
					touchable = false
					local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
					local Anims = humanoid.Parent:FindFirstChild("Anims")
					local HitStunRight = Anims:FindFirstChild("HitStunRight")
					local LtrackRight = humanoid:LoadAnimation(HitStunRight)
					humanoid:TakeDamage(10)
					LtrackRight:Play()
					local blood = game.ServerStorage.BloodPartForFist:Clone()
					blood.Position = humanoid.Parent:FindFirstChild("Head").Position
					blood.Parent = humanoid.Parent
					local KnockBack = Instance.new("BodyVelocity")
					KnockBack.P = math.huge
					KnockBack.Parent = humanoid.Parent:FindFirstChild("HumanoidRootPart")
					KnockBack.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
					KnockBack.Velocity = tool.Parent:FindFirstChild("HumanoidRootPart").CFrame.lookVector * 5
					game.Debris:AddItem(KnockBack, 0.2)
					wait(0.5)
					blood:Remove()
					LtrackRight:Stop()
					LtrackRight:Remove()
					end
				hitbox:Remove()
		end)
	end)
	
	heavy.OnServerEvent:Connect(function()
		local hitbox = game.ServerStorage.Hitbox:Clone()
		hitbox.Parent = tool.Parent
		hitbox.CFrame = tool.Parent:FindFirstChild("HumanoidRootPart").CFrame:ToWorldSpace(CFrame.new(0,0,-3))
		LightAnims[math.random(1,2)]:Play()
		touchable = true
		hitbox.Touched:Connect(function(otherPart)
			if otherPart.Parent == tool.Parent then
				return
			end
			if touchable == true then
				touchable = false
				local humanoid = otherPart.Parent:FindFirstChild("Humanoid")
				local Anims = humanoid.Parent:FindFirstChild("Anims")
				local HitStunRight = Anims:FindFirstChild("HitStunRight")
				local LtrackRight = humanoid:LoadAnimation(HitStunRight)
				humanoid:TakeDamage(10)
				LtrackRight:Play()
				local blood = game.ServerStorage.BloodPartForFist:Clone()
				blood.Position = humanoid.Parent:FindFirstChild("Head").Position
				blood.Parent = humanoid.Parent
				local KnockBack = Instance.new("BodyVelocity")
				KnockBack.P = math.huge
				KnockBack.Parent = humanoid.Parent:FindFirstChild("HumanoidRootPart")
				KnockBack.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
				KnockBack.Velocity = tool.Parent:FindFirstChild("HumanoidRootPart").CFrame.lookVector * 5
				game.Debris:AddItem(KnockBack, 0.2)
				wait(0.5)
				blood:Remove()
				LtrackRight:Stop()
				LtrackRight:Remove()
			end
			end)
			hitbox:Remove()
		end)
	end)

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

2 Likes

i copied the light script but just change the remote event,and its still not working

2 Likes

the animation is playing corrrectly but hitbox is not working

i fixed the problem nvm i just forgot to add a wait before remove hitbox so it got removed immediately as soon as it cloned