So I have a script inside of a Monster NPC that does stuff when it dies. (it's health get lowered when it touches a block called 'IceCube'. It worked in a different place, and when I tried it out in 'Run' mode it also worked. I even named a part 'IceCube' and killed him with that and everything worked
Then when I went to 'play solo' and used the water bucket, It still did damage and killed him, it's just the script didn't work
2 errors came up only on 'play solo':
17:17:16.946 - Torso is not a valid member of Part 17:17:16.947 - Script 'Workspace.Lava Monster.Head.DeathSound', Line 3 17:17:16.948 - Stack End 17:17:16.948 - Disconnected event because of exception 17:17:18.134 - Humanoid is not a valid member of Model 17:17:18.135 - Script 'Workspace.Lava Monster.Monster', Line 41 17:17:18.135 - Stack End
Here's the script:
script.Parent.Parent:WaitForChild("Humanoid").Died:connect(function() script.Parent.Parent.Torso.BrickColor = BrickColor.new("Really black") script.Parent.Parent["Left Arm"].BrickColor = BrickColor.new("Really black") script.Parent.Parent["Left Leg"].BrickColor = BrickColor.new("Really black") script.Parent.Parent["Right Arm"].BrickColor = BrickColor.new("Really black") script.Parent.Parent["Right Leg"].BrickColor = BrickColor.new("Really black") script.Parent.Parent.Monster:Destroy() script.Parent.Roar:Play() wait(1.5) game.Workspace.Crumble:Play() script.Parent.Parent.Torso.Fire.Enabled = false script.Parent.Parent.Torso.Smoke.Enabled = true wait(4) script.Parent.Parent.Torso.Smoke.Enabled = false end)
The problem is that Torso
, and Humanoid
has not loaded yet, so when the script fired, it did not find Torso
or Humanoid
, I have remade your script with some-what explanations, you could simply use the WaitForChild method [Which I did not use but should've :P], and that would've waited until the Torso
and Humanoid
have loaded;
function WaitForChild(str,obj) --I have created a new function for you; this will help to wait for the Child; not necesary, could've simply used 'str:WaitForChild(obj)', but eh :P repeat wait() until str:FindFirstChild(obj) --This will repeat until the code finds 'obj' within 'str' return str:FindFirstChild(obj) --This will return 'obj' when it is found end --This ends the code block for the function local Figure = script.Parent.Parent --Figure is the Script's Parent's Parent local Torso = WaitForChild(Figure,"Torso") --This will repeat until 'Torso' is existant within 'Figure', and will return it local LeftArm = WaitForChild(Figure,"Left Arm") --This will repeat until 'Left Arm' is existant within 'Figure', and will return it local RightArm = WaitForChild(Figure,"Right Arm") --This will repeat until 'Right Arm' is existant within 'Figure', and will return it local LeftLeg = WaitForChild(Figure,"Left Leg") --This will repeat until 'Left Leg' is existant within 'Figure', and will return it local RightLeg = WaitForChild(Figure,"Right Leg") --This will repeat until 'Right Leg' is existant within 'Figure', and will return it local Humanoid = WaitForChild(Figure,"Humanoid") --This will repeat until 'Humanoid' is existant within 'Figure', and will return it WaitForChild(script.Parent,"Roar") --This will repeat until 'Roar' is existant within the Script's Parent WaitForChild(Figure,"Monster") --This will repeat until 'Monster' is existant within 'Figure' WaitForChild(game.Workspace,"Crumble") --This will repeat until 'Crumble' is existant within 'game.Workspace' WaitForChild(Torso,"Fire") --This will repeat until 'Fire' is existant within 'Torso' WaitForChild(Torso,"Smoke") --This will repeat until 'Smoke' is existant within 'Torso' Humanoid.Died:connect(function() --This will fire when the Humanoid dies Torso.BrickColor = BrickColor.new("Really black") --This will turn 'Torso''s BrickColor to 'Really black' LeftArm.BrickColor = BrickColor.new("Really black") --So on LeftLeg.BrickColor = BrickColor.new("Really black") --So on RightArm.BrickColor = BrickColor.new("Really black") --So on RightLeg.BrickColor = BrickColor.new("Really black") --And so on Figure.Monster:Destroy() --This will destroy 'Monster' within 'Figure' script.Parent.Roar:Play() --This will play the 'Sound' 'Roar' wait(1.5) --Will wait '1.5' seconds [One and a half] game.Workspace.Crumble:Play() --Will play the 'Sound' 'Crumble' Torso.Fire.Enabled = false --This will disable the 'Fire' type instance within 'Torso' Torso.Smoke.Enabled = true --This will enable the 'Smoke' type instance within 'Torso' wait(4) --Will wait '4' seconds Torso.Smoke.Enabled = false --This will disable the 'Smoke' type instance within 'Torso' end) --This ends the code block for the Function/Event
Hope this helped!
Yeah I have scripts that won't work in solo either.Your best bet is just to play your game to test it.
Locked by TheMyrco
This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.
Why was this question closed?