generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: If Parts Then Tool

Previous Thread :: Next Thread 
EgoRenascitur is not online. EgoRenascitur
Joined: 17 Nov 2013
Total Posts: 1049
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
PerpetualMovement is not online. PerpetualMovement
Joined: 04 Dec 2012
Total Posts: 1001
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
EgoRenascitur is not online. EgoRenascitur
Joined: 17 Nov 2013
Total Posts: 1049
16 Jun 2014 09:07 PM
I tried adding that script but even after fixing the typo, it still isn't working.
Report Abuse
EgoRenascitur is not online. EgoRenascitur
Joined: 17 Nov 2013
Total Posts: 1049
16 Jun 2014 09:16 PM
Bump.
Report Abuse
PerpetualMovement is not online. PerpetualMovement
Joined: 04 Dec 2012
Total Posts: 1001
16 Jun 2014 09:17 PM
What does it say in the output?
Report Abuse
EgoRenascitur is not online. EgoRenascitur
Joined: 17 Nov 2013
Total Posts: 1049
16 Jun 2014 09:20 PM
It doesn't say anything about that script.
Report Abuse
PerpetualMovement is not online. PerpetualMovement
Joined: 04 Dec 2012
Total Posts: 1001
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
EgoRenascitur is not online. EgoRenascitur
Joined: 17 Nov 2013
Total Posts: 1049
16 Jun 2014 09:22 PM
Added when I pick them up.
Report Abuse
PerpetualMovement is not online. PerpetualMovement
Joined: 04 Dec 2012
Total Posts: 1001
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
EgoRenascitur is not online. EgoRenascitur
Joined: 17 Nov 2013
Total Posts: 1049
16 Jun 2014 09:26 PM
Yep, I just checked again. I don't know why it isn't working out.
Report Abuse
PerpetualMovement is not online. PerpetualMovement
Joined: 04 Dec 2012
Total Posts: 1001
16 Jun 2014 09:28 PM
This script is located in the Player right?
Report Abuse
EgoRenascitur is not online. EgoRenascitur
Joined: 17 Nov 2013
Total Posts: 1049
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
PerpetualMovement is not online. PerpetualMovement
Joined: 04 Dec 2012
Total Posts: 1001
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
EgoRenascitur is not online. EgoRenascitur
Joined: 17 Nov 2013
Total Posts: 1049
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
EgoRenascitur is not online. EgoRenascitur
Joined: 17 Nov 2013
Total Posts: 1049
16 Jun 2014 09:39 PM
I also have to go to bed now, so I'll bump the thread tomorrow.
Report Abuse
islandmaker2012 is online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
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
EgoRenascitur is not online. EgoRenascitur
Joined: 17 Nov 2013
Total Posts: 1049
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image