|
| 16 Jun 2014 08:54 PM |
I'm trying to have it that when a player holds four tools in his backpack, he will then receive a brand new tool called "Finisher."
My Attempt:
script.Parent.Backpack.ChildAdded:connect(function(obj) for i,v in pairs(script.Parent.Backpack()) do if v.Name == "TOne" then for i,e in pairs(script.Parent.Backpack()) do if e.Name == "TTwo" then for i,c in pairs(script.Parent.Backpack()) do if c.Name == "TThree" then for i,x in pairs(script.Parent.Backpack()) do if x.Name == "TFour" then game.Lighting.Finisher:Clone().Parent = script.Parent.Backpack end end end end end end end end end) |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 08:58 PM |
script.Parent.Backpack.ChildAdded:connect(function(obj) local bp = script.Parent.Backpack if bp:FindFirstChild("TOne") and bp:FindFirstChild("TTwo") and bp:FindFirstChild("TThree") and bp:FindFirstChild("TFour") then game.Lighting.Finished:Clone().Parent = bp end end) |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 09:07 PM |
| I tried adding that script but even after fixing the typo, it still isn't working. |
|
|
| Report Abuse |
|
|
| |
|
|
| 16 Jun 2014 09:17 PM |
| What does it say in the output? |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 09:20 PM |
| It doesn't say anything about that script. |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 09:22 PM |
| Well, it should work. Are you spawning with TOne, TTwo, etc? Or are they added to the backpack? |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 09:22 PM |
| Added when I pick them up. |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 09:24 PM |
| Well, since you're not getting anything in the output, it has something to do with the if statement. Are you sure you have all of the tools listed and are spelled the same? |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 09:26 PM |
| Yep, I just checked again. I don't know why it isn't working out. |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 09:28 PM |
| This script is located in the Player right? |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 09:29 PM |
I also know the parents are right because I used this script to add that script into the player:
game.Players.PlayerAdded:connect(function(plr) wait(0.5) local evil = Instance.new("BoolValue") evil.Name = "Evil" evil.Value = false evil.Parent = plr local paper = game.ServerScriptService.GiveIf:Clone() paper.Parent = plr end) |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 09:32 PM |
I think i know the problem. Try disabling the script, GiveIf inside ServerScriptService. Scripts do runs inside the service so there should've been an error, since Backpack is not a member of ServerScriptService
game.Players.PlayerAdded:connect(function(plr) wait(0.5) local evil = Instance.new("BoolValue") evil.Name = "Evil" evil.Value = false evil.Parent = plr local paper = game.ServerScriptService.GiveIf:Clone() paper.Parent = plr paper.Disabled = false end) |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 09:38 PM |
| I just tried that now, I even added a wait between defining its parent and Disabled = false, but it still isn't working out. |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 09:39 PM |
| I also have to go to bed now, so I'll bump the thread tomorrow. |
|
|
| Report Abuse |
|
|
|
| 16 Jun 2014 09:39 PM |
scripts will not run as a direct child of player(any kind of script)
it has to run in a child of player, such as playergui,backpack..
(also works in character) |
|
|
| Report Abuse |
|
|
|
| 17 Jun 2014 01:56 PM |
@island
You were right, I just modified the script to work from Backpack and it's working perfectly.
Thank both of you for your help. |
|
|
| Report Abuse |
|
|