Summary of what I'm trying to do; I'm making a combat tool where if you hit someone you do damage. It all worked perfectly the first time but the second time it fails. I used the print method and did find something but I don't know how to fix this. I posted this many times now and was never answered so I decided this probably is on the harder side to answer.
For more info on the game; https://web.roblox.com/games/756392385/New-Project Here's my ENTIRE script;
local CombatTool = script.Parent local Animation = game.ReplicatedStorage:WaitForChild("CombatAnimation") local Damage = CombatTool:WaitForChild("Damage") local StaminaUse = CombatTool:WaitForChild("StaminaUse") local CurrentStrengthStat = CombatTool.Parent.Parent:WaitForChild("Status").CurrentStrength local CurrentStamina = CombatTool.Parent.Parent:WaitForChild("Status"):WaitForChild("CurrentStamina") local CurrentStaminaStat = CombatTool.Parent.Parent:WaitForChild("Status"):WaitForChild("CurrentStaminaStat") local Fighting = false print("All Variables Defined, Location: CombatTool.CombatScript") function onActivation() if CurrentStamina.Value >= StaminaUse.Value then print("Combat Tool has been activated and player has enough stamina") local AnimeHumanoid = CombatTool.Parent:WaitForChild("Humanoid") local LoadAnime = AnimeHumanoid:LoadAnimation(Animation) LoadAnime:Play() print("Animation Has been Loaded, playing...") CurrentStamina.Value = CurrentStamina.Value - StaminaUse.Value wait() CurrentStaminaStat.Value = CurrentStaminaStat.Value + Damage.Value Damage.Value = Damage.Value + CurrentStrengthStat.Value CurrentStrengthStat.Value = CurrentStrengthStat.Value + StaminaUse.Value print("Stats have been calculated") CombatTool.Parent:WaitForChild("Right Arm").Touched:connect(function(Hit) if not Fighting then Fighting = true print("Fighting Became True For The Right Arm") if Hit.Parent:FindFirstChild("Humanoid") then Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - Damage.Value Fighting = false CombatTool.Parent:WaitForChild("Right Leg").Touched:connect(function(Hit) if not Fighting then Fighting = true print("Fighting Became True For The Right Leg") if Hit.Parent:FindFirstChild("Humanoid") then Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - Damage.Value Fighting = false print("Completed") end end end) end end end) end end CombatTool.Activated:connect(onActivation)
This is my ENTIRE Output after 2 uses of CombatTool
12:46:54.117 - New Project @ 07 May 2017 12:46 was auto-saved Ragdoll Physics Loaded Hello world! 12:46:57.495 - Humanoid is not a valid member of Script 12:46:57.496 - Stack Begin 12:46:57.498 - Script 'Plugin_144773946.RealRagdoll.Ragdoll', Line 4 12:46:57.499 - Stack End Loading Cutscene Editor... Bouyer's Ragdoll Physics Loaded Finished Loading. Loading Tree Gen... Finished Loading Tree Gen 12:46:58.392 - Unable to load plugin icon. (x2) All Variables Defined, Location: CombatTool.CombatScript 12:46:59.103 - TestService: Shop plugin by UltraWorks is outdated. Please click the 'Manage Plugins' button and update to the latest version. This version: [2.1.6] Please update to: [2.1.7] Realism Mod is running on v1.795! Cutscene Editor Loaded Hello world! Combat Tool has been activated and player has enough stamina Animation Has been Loaded, playing... Stats have been calculated Fighting Became True For The Right Arm (x4) Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Arm (x8) Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Arm Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Leg Completed Fighting Became True For The Right Arm (x2) Fighting Became True For The Right Leg Combat Tool has been activated and player has enough stamina Animation Has been Loaded, playing... Stats have been calculated
Every time I use combat tool it will print "Combat Tool has been activated and player has enough stamina"
so look for those parts to know what printed the first time and second time
Here's the part that stopped at the second time;
CombatTool.Parent:WaitForChild("Right Arm").Touched:connect(function(Hit) if not Fighting then Fighting = true print("Fighting Became True For The Right Arm") if Hit.Parent:FindFirstChild("Humanoid") then Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - Damage.Value Fighting = false CombatTool.Parent:WaitForChild("Right Leg").Touched:connect(function(Hit) if not Fighting then Fighting = true print("Fighting Became True For The Right Leg") if Hit.Parent:FindFirstChild("Humanoid") then Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - Damage.Value Fighting = false print("Completed")
It printed "Stats have been calculated" at the end but didn't print anything else so this part probably went wrong.
Please help me! I need; - Feedback - Explanations - Why it doesn't work - How to fix - A script that will work the same way - Help Thank you for any feedback.