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 » Scripters
Home Search
 

Re: Script not working

Previous Thread :: Next Thread 
iamarobloxfan is not online. iamarobloxfan
Joined: 30 Sep 2011
Total Posts: 2343
16 Jul 2015 07:02 PM
This script is supposed to look through the table "icecoffees", and see if whatever's touching it has one of the names in icecoffees, and if it does, it puts "Iced" at the beginning of it. However, this script does absolutely nothing, and the output doesn't say anything.

local icecoffees = {"Coffee", "Espresso"}

function touch(hit)
if hit.Parent then
local gear = hit.Parent:findFirstChild(icecoffees)
if gear then
gear.Name = ("Iced " ..gear.Name)
script.Parent.pour:Play()
wait(1)
script.Parent.pour:Pause()
end
end
end
script.Parent.Touched:connect(touch)

Yes, this is a repost, but I didn't explain it well enough.

OT's Opinions are pineapples to me.
Report Abuse
Locard is not online. Locard
Joined: 13 Apr 2014
Total Posts: 3516
16 Jul 2015 07:06 PM
icedcoffees is a table, not a string. FindFirstChild looks for names (which are strings) of objects inside the object the method is calling for. Therefore gear would be nil, or FindFirstChild would error.
Report Abuse
iamarobloxfan is not online. iamarobloxfan
Joined: 30 Sep 2011
Total Posts: 2343
16 Jul 2015 07:07 PM
What can I use for tables then?

OT's Opinions are pineapples to me.
Report Abuse
CrowClaws is not online. CrowClaws
Joined: 04 Jul 2010
Total Posts: 4466
16 Jul 2015 07:07 PM
you have to do something like

local gear = hit.Parent:findFirstChild(icecoffees[1]) or hit.Parent:findFirstChild(icecoffees[2])
Report Abuse
iamarobloxfan is not online. iamarobloxfan
Joined: 30 Sep 2011
Total Posts: 2343
16 Jul 2015 07:08 PM
Is there a more efficient way, Crow? There's going to be a lot of strings in the table...

OT's Opinions are pineapples to me.
Report Abuse
CrowClaws is not online. CrowClaws
Joined: 04 Jul 2010
Total Posts: 4466
16 Jul 2015 07:09 PM
well for what you have setup.no
but i don't know what you are doing lmao
Report Abuse
iamarobloxfan is not online. iamarobloxfan
Joined: 30 Sep 2011
Total Posts: 2343
16 Jul 2015 07:10 PM
Trying to find a cup using Touched, then attempting to change the name to whatever it is to "Iced", then whatever it is.

OT's Opinions are pineapples to me.
Report Abuse
CrowClaws is not online. CrowClaws
Joined: 04 Jul 2010
Total Posts: 4466
16 Jul 2015 07:11 PM
like
wtf

local gear = hit.Parent:findFirstChild(icecoffees)

what are u trying to find
Report Abuse
iamarobloxfan is not online. iamarobloxfan
Joined: 30 Sep 2011
Total Posts: 2343
16 Jul 2015 07:13 PM
Okay, I know, that was really stupid.
I'm trying to find a gear with the name "Coffee" or "Espresso".

OT's Opinions are pineapples to me.
Report Abuse
iamarobloxfan is not online. iamarobloxfan
Joined: 30 Sep 2011
Total Posts: 2343
16 Jul 2015 07:19 PM
bump

OT's Opinions are pineapples to me.
Report Abuse
iamarobloxfan is not online. iamarobloxfan
Joined: 30 Sep 2011
Total Posts: 2343
16 Jul 2015 07:20 PM
nevermind, I'll just set some variables and make it look a little cleaner.

OT's Opinions are pineapples to me.
Report Abuse
lolb3 is not online. lolb3
Joined: 16 Jan 2010
Total Posts: 2268
16 Jul 2015 07:27 PM
local icecoffees = {"Coffee", "Espresso"}

function touch(hit)
if hit.Parent then
for i=1,#icecoffees do
if string.lower(icecoffees[i].Name)==string.lower(gear.Name) then
gear.Name = ("Iced " ..gear.Name)
script.Parent.pour:Play()
wait(1)
script.Parent.pour:Pause()
end
end
end
script.Parent.Touched:connect(touch)

clean doesnt look cool dude, the nastier the better
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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