|
| 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
|
  |
| 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 |
|
|
|
| 16 Jul 2015 07:07 PM |
What can I use for tables then?
OT's Opinions are pineapples to me. |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 16 Jul 2015 07:19 PM |
bump
OT's Opinions are pineapples to me. |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|