Here's my entire script;

local Combat = script.Parent
local Animation = game.ReplicatedStorage:WaitForChild("CombatAnimation")
local Fighting = false
local Damage = script.Parent:WaitForChild("Damage")
local StaminaUse = script.Parent:WaitForChild("StaminaUse")
local CurrentStrength = Combat.Parent.Parent:WaitForChild("Status"):WaitForChild("CurrentStrength")
local CurrentStamina = Combat.Parent.Parent:WaitForChild("Status"):WaitForChild("CurrentStamina")
local CurrentStaminaStat = Combat.Parent.Parent:WaitForChild("Status"):WaitForChild("CurrentStaminaStat")
print("All Variables Defined")

function onActivation()
	if CurrentStamina.Value >= 10 then
		print("Combat Tool Activated")
		local Humanoid = Combat.Parent:WaitForChild("Humanoid")
		local anim = Humanoid:LoadAnimation(Animation)
   		anim:Play()
		print("Playing Animation")
		CurrentStamina.Value = CurrentStamina.Value - StaminaUse.Value
		CurrentStaminaStat.Value = CurrentStaminaStat.Value + StaminaUse.Value
    	CurrentStrength.Value = CurrentStrength.Value + StaminaUse.Value
		print("Added and Subtracted all stats")
		Combat.Parent:WaitForChild("Right Arm").Touched:connect(function(Hit)
			if not Fighting then
				Fighting = true
				if Hit.Parent:FindFirstChild("Humanoid") then
					Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - Damage.Value
					if Fighting then
						Fighting = false
						Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - 0
						wait()
						print("Combat Right Arm Has been completed")
						Combat.Parent:WaitForChild("Right Leg").Touched:connect(function(Hit)
							if not Fighting then
								Fighting = true
								if Hit.Parent:FindFirstChild("Humanoid") then
									Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - Damage.Value
									wait()
									if Fighting then
										Fighting = false
										Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - 0
										print("Completed")
									end
								end
							end
						end)
					end
				end
			end
		end)
	end
end

Combat.Activated:connect(onActivation)

Here's what it printed;

All Variables Defined
Realism Mod is running on v1.795!
Cutscene Editor Loaded
Hello world!
Combat Tool Activated
Playing Animation
Added and Subtracted all stats
Combat Right Arm Has been completed (x4)
Completed (x3)
Combat Right Arm Has been completed
Completed (x5)
Combat Right Arm Has been completed (x2)
Completed
Combat Tool Activated -- the Second time
Playing Animation
Added and Subtracted all stats
Combat Tool Activated
Playing Animation
Added and Subtracted all stats
Combat Tool Activated
Playing Animation
Added and Subtracted all stats
Combat Tool Activated
Playing Animation
Added and Subtracted all stats

As we can see, Combat Right Arm was printed but then the second time I tried it didn't work. I placed where the second time is. It runs when it prints Combat Tool Activated.

Here's the part of the script I think is going wrong;

local Combat = script.Parent
local Animation = game.ReplicatedStorage:WaitForChild("CombatAnimation")
local Fighting = false
local Damage = script.Parent:WaitForChild("Damage")
local StaminaUse = script.Parent:WaitForChild("StaminaUse")
local CurrentStrength = Combat.Parent.Parent:WaitForChild("Status"):WaitForChild("CurrentStrength")
local CurrentStamina = Combat.Parent.Parent:WaitForChild("Status"):WaitForChild("CurrentStamina")
local CurrentStaminaStat = Combat.Parent.Parent:WaitForChild("Status"):WaitForChild("CurrentStaminaStat")
print("All Variables Defined")

function onActivation()
	if CurrentStamina.Value >= 10 then
		print("Combat Tool Activated")
		local Humanoid = Combat.Parent:WaitForChild("Humanoid")
		local anim = Humanoid:LoadAnimation(Animation)
   		anim:Play()
		print("Playing Animation")
		CurrentStamina.Value = CurrentStamina.Value - StaminaUse.Value
		CurrentStaminaStat.Value = CurrentStaminaStat.Value + StaminaUse.Value
    	CurrentStrength.Value = CurrentStrength.Value + StaminaUse.Value
		print("Added and Subtracted all stats")
		Combat.Parent:WaitForChild("Right Arm").Touched:connect(function(Hit)
			if not Fighting then 
				Fighting = true
				if Hit.Parent:FindFirstChild("Humanoid") then -- stops somewhere under here
					Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - Damage.Value
					if Fighting then
						Fighting = false
						Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - 0
						wait()
						print("Combat Right Arm Has been completed")
						Combat.Parent:WaitForChild("Right Leg").Touched:connect(function(Hit)
							if not Fighting then
								Fighting = true
								if Hit.Parent:FindFirstChild("Humanoid") then
									Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - Damage.Value
									wait()
									if Fighting then
										Fighting = false --Set's to false
										Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - 0
										print("Completed")
									end
								end
							end
						end)
					end
				end
			end
		end)
	end
end

Combat.Activated:connect(onActivation)

I added --Messages.

Here's my ENTIRE output if you somewhat need it;

19:27:29.228 - New Project @ 06 May 2017 19:27 was auto-saved
Ragdoll Physics Loaded
Hello world!
19:27:41.212 - Humanoid is not a valid member of Script
19:27:41.213 - Stack Begin
19:27:41.214 - Script 'Plugin_144773946.RealRagdoll.Ragdoll', Line 4
19:27:41.215 - Stack End
Loading Cutscene Editor...
Bouyer's Ragdoll Physics Loaded
Finished Loading.
Loading Tree Gen...
Finished Loading Tree Gen
19:27:42.653 - Unable to load plugin icon. (x2)
All Variables Defined
Realism Mod is running on v1.795!
Cutscene Editor Loaded
Hello world!
Combat Tool Activated
Playing Animation
Added and Subtracted all stats
Combat Right Arm Has been completed (x4)
Completed (x3)
Combat Right Arm Has been completed
Completed (x5)
Combat Right Arm Has been completed (x2)
Completed
Combat Tool Activated
Playing Animation
Added and Subtracted all stats
Combat Tool Activated
Playing Animation
Added and Subtracted all stats
Combat Tool Activated
Playing Animation
Added and Subtracted all stats
Combat Tool Activated
Playing Animation
Added and Subtracted all stats
19:33:41.403 - New Project was auto-saved (x2)

Lastly here's a short summary of what I'm trying to do;

I'm trying to make a combat tool where when clicked you fight. The first time it runs PERFECTLY. The second time you click it doesn't do damage anymore and that's where it stops working. All I'm trying to do is make it so every time you click it, it does damage. I also don't want it to spam damage.

What I need; -Someone to help me fix this -Someone who will make this script different but then functions the same way I want it. -Feedback -Suggestions -What to add and remove -What's gone wrong -And explanation why this script isn't working -How I (me) would fix this

Thanks you all for reading and I hope I get some feedback.

2 comments

0

We don't need your entire output just the part that connects to the script .

0

and I posted it