Please help! This is the ENTIRE output;
20:07:16.541 - New Project @ 30 Apr 2017 20:07 was auto-saved Ragdoll Physics Loaded Hello world! 20:07:19.599 - Humanoid is not a valid member of Script 20:07:19.600 - Stack Begin 20:07:19.601 - Script 'Plugin_144773946.RealRagdoll.Ragdoll', Line 4 20:07:19.602 - Stack End Loading Cutscene Editor... Bouyer's Ragdoll Physics Loaded Finished Loading. Loading Tree Gen... Finished Loading Tree Gen 20:07:20.496 - Unable to load plugin icon. (x2) Realism Mod is running on v1.795! Cutscene Editor Loaded Hello world! Death Hello world! Magnet Punch! Consuming Powers... Death 20:07:44.920 - Infinite yield possible on 'Workspace:WaitForChild("Humanoid")' 20:07:44.922 - Stack Begin 20:07:44.924 - Script 'Players.Player1.Backpack.Combat.Main', Line 25 20:07:44.925 - Stack End 20:07:45.389 - Infinite yield possible on 'Workspace:WaitForChild("Humanoid")' 20:07:45.391 - Stack Begin 20:07:45.392 - Script 'Players.Player1.Backpack.Combat.Main', Line 25 20:07:45.394 - Stack End Hello world! 20:07:47.342 - Infinite yield possible on 'Players.Player1.Backpack:WaitForChild("Right Leg")' (x3) 20:07:47.362 - Infinite yield possible on 'Workspace.Player1.Ultra-Fabulous Hair:WaitForChild("Humanoid")' 20:07:47.609 - Infinite yield possible on 'Workspace.Player1:WaitForChild("Humanoid")' (x4) 20:07:47.657 - Infinite yield possible on 'Workspace:WaitForChild("Humanoid")' 20:07:47.724 - Infinite yield possible on 'Workspace.Player1:WaitForChild("Humanoid")' 20:07:47.775 - Infinite yield possible on 'Workspace:WaitForChild("Humanoid")' 20:08:41.643 - Sent message to server to publish.
This is the script that had a problem;
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") local ToolActivated = false function onActivation() ToolActivated = true print("Magnet Punch!") local Humanoid = Combat.Parent:WaitForChild("Humanoid") local anim = Humanoid:LoadAnimation(Animation) anim:Play() if Fighting == false then Fighting = true CurrentStamina.Value = CurrentStamina.Value - StaminaUse.Value CurrentStaminaStat.Value = CurrentStaminaStat.Value + StaminaUse.Value CurrentStrength.Value = CurrentStrength.Value + StaminaUse.Value Combat.Parent:WaitForChild("Right Arm").Touched:connect(function(Hit) Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - Damage.Value Combat.Parent:WaitForChild("Right Leg").Touched:connect(function(Hit) Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - Damage.Value wait() Fighting = false if ToolActivated == false then return end end) end) end end Combat.Activated:connect(onActivation)
This is the line the where the problem was;
Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - Damage.Value
But where did All the other Infinite yield came from!? What is happening? Please help!
You simply need to make sure that a Humanoid actually exists before waiting for it, so you should use a FindFirstChild
check before waiting. Use this updated code that I added the FindFirstChild
if statement to.
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") local ToolActivated = false function onActivation() ToolActivated = true print("Magnet Punch!") local Humanoid = Combat.Parent:WaitForChild("Humanoid") local anim = Humanoid:LoadAnimation(Animation) anim:Play() if Fighting == false then Fighting = true CurrentStamina.Value = CurrentStamina.Value - StaminaUse.Value CurrentStaminaStat.Value = CurrentStaminaStat.Value + StaminaUse.Value CurrentStrength.Value = CurrentStrength.Value + StaminaUse.Value Combat.Parent:WaitForChild("Right Arm").Touched:connect(function(Hit) if Hit.Parent:FindFirstChild("Humanoid") then Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - Damage.Value Combat.Parent:WaitForChild("Right Leg").Touched:connect(function(Hit) if Hit.Parent:FindFirstChild("Humanoid") then Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - Damage.Value wait() Fighting = false if ToolActivated == false then return end end end) end end) end end Combat.Activated:connect(onActivation)
I'm not fully sure if this script will work, mostly because i wasn't able to test it myself, but here is the script that is maybe fixed.
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") local ToolActivated = false function onActivation() ToolActivated = true print("Magnet Punch!") local Humanoid = Combat.Parent:WaitForChild("Humanoid") local anim = Humanoid:LoadAnimation(Animation) anim:Play() Fighting = true if Fighting == true then return end Fighting = true CurrentStamina.Value = CurrentStamina.Value - StaminaUse.Value CurrentStaminaStat.Value = CurrentStaminaStat.Value + StaminaUse.Value CurrentStrength.Value = CurrentStrength.Value + StaminaUse.Value Combat.Parent:WaitForChild("Right Arm").Touched:connect(function(Hit) Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - Damage.Value Combat.Parent:WaitForChild("Right Leg").Touched:connect(function(Hit) Hit.Parent:WaitForChild("Humanoid").Health = Hit.Parent:WaitForChild("Humanoid").Health - Damage.Value wait() Fighting = false if ToolActivated == false then return end end) end) end Combat.Activated:connect(onActivation)