|
| 22 Jun 2014 06:20 AM |
Would this create problems because there are so many if statements and different combinations...
And by problem I mean not allowing the script to work properly.
function onClicked(player) if Workspace:FindFirstChild("Strawberries") and Workspace:FindFirstChild("Milk")then wait(5.4) game.Workspace.Milk:Remove() game.Workspace.Strawberries:Remove() game.Lighting.StrawberrySwirl:Clone().Parent = game.Workspace local message = Instance.new("Hint") message.Parent = game.Workspace message.Text = "You made a strawberry swirl smoothie!" wait(3) message:Remove() end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
function onClicked(player) if Workspace:FindFirstChild("Blueberries") and Workspace:FindFirstChild("Milk")then wait(5.4) game.Workspace.Milk:Remove() game.Workspace.Blueberries:Remove() game.Lighting.BlueberrySplash:Clone().Parent = game.Workspace local message = Instance.new("Hint") message.Parent = game.Workspace message.Text = "You made a blueberry splash smoothie!" wait(3) message:Remove() end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
function onClicked(player) if Workspace:FindFirstChild("Milk") then wait(5.4) game.Workspace.Milk:Remove() game.Lighting.Milk:Clone().Parent = game.Workspace local message = Instance.new("Hint") message.Parent = game.Workspace message.Text = "You made plain milk!" wait(3) message:Remove() end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
function onClicked(player) if Workspace:FindFirstChild("Strawberries") then wait(5.4) game.Workspace.Strawberries:Remove() game.Lighting.BlendedStrawberries:Clone().Parent = game.Workspace local message = Instance.new("Hint") message.Parent = game.Workspace message.Text = "You made crushed strawberries!" wait(3) message:Remove() end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
function onClicked(player) if Workspace:FindFirstChild("Blueberries") then wait(5.4) game.Workspace.Blueberries:Remove() game.Lighting.BlendedBlueberries:Clone().Parent = game.Workspace local message = Instance.new("Hint") message.Parent = game.Workspace message.Text = "You made some blended blueberries!" wait(3) message:Remove() end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
function onClicked(player) if Workspace:FindFirstChild("Bananas") then wait(5.4) game.Workspace.Bananas:Remove() game.Lighting.BlendedBananas:Clone().Parent = game.Workspace local message = Instance.new("Hint") message.Parent = game.Workspace message.Text = "You made sliced bananas!" wait(3) message:Remove() end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
|
|
|
| Report Abuse |
|
|
|
| 22 Jun 2014 06:25 AM |
I'm pretty sure I need to come up with a new way to do this...
Anyone have any ideas? |
|
|
| Report Abuse |
|
|
|
| 22 Jun 2014 06:35 AM |
Fruits = {["Strawberries"] = "crushed",["Bananas"] = "sliced",["Blueberries"] = "blended"}
script.Parent.MouseClick:connect(function() for i,v in pairs(Fruits) do if Workspace:FindFirstChild(i) then wait(5.4) Workspace[i]:Destroy() Message = Instance.new("Hint",Workspace) game:GetService("Debris"):AddItem(Message,3) Message.Text = "You made" .. v .. i .. "!" end end end) |
|
|
| Report Abuse |
|
|
|
| 22 Jun 2014 06:36 AM |
| Can you explain this to me? |
|
|
| Report Abuse |
|
|
|
| 22 Jun 2014 06:43 AM |
Fruits = {["Strawberries"] = "crushed",["Bananas"] = "sliced",["Blueberries"] = "blended"} >Dictionary with index set to the fruit, value set to the type you'd create. http://wiki.roblox.com/index.php?title=Dictionary#Dictionaries
script.Parent.MouseClick:connect(function() Generic/Anonymous function http://wiki.roblox.com/index.php?title=Function#Dictionaries
for i,v in pairs(Fruits) do >For loop looking through each item in the table one at a time http://wiki.roblox.com/index.php?title=Generic_for
if Workspace:FindFirstChild(i) then >Standard if statement using the index returned from the table Not bothering to link this.
wait(5.4) >Your wait time Derp
Workspace[i]:Destroy() >Destroying item should the if statement return true. Use Destroy rather then Remove if you don't plan to use the object again. Not going to link
Message = Instance.new("Hint",Workspace) >Creating the message. No link. You clearly know this part.
game:GetService("Debris"):AddItem(Message,3) >Debris is more reliable. http://wiki.roblox.com/index.php?title=Service http://wiki.roblox.com/index.php?title=Debris
Message.Text = "You made" .. v .. i .. "!" >Changing the text to the Value in the table then the Index.
end end end) |
|
|
| Report Abuse |
|
|
|
| 22 Jun 2014 06:46 AM |
I just don't understand how the message text part would work the way it used to.
|
|
|
| Report Abuse |
|
|
|
| 22 Jun 2014 06:50 AM |
Fruits = {["Strawberries"] = "crushed",["Bananas"] = "sliced",["Blueberries"] = "blended"} Message.Text = "You made" .. v .. i .. "!"
Let's say you were looking at the first one.
v would be "crushed" and i would be "strawberries"
The text would be: "You made" .. "crushed" .. "Strawberries" .. ! or You madecrushedStrawberries!
So you could actually put some spaces... |
|
|
| Report Abuse |
|
|
|
| 22 Jun 2014 06:54 AM |
But what about adding the milk and other smoothies?
Such as the strawberry swirl? |
|
|
| Report Abuse |
|
|
|
| 22 Jun 2014 07:19 AM |
Recipes = { ["Disaster Smoothie"] = {{"Potato","Onion","Dirt","Carrot"}, "You've made a mess!" } }
script.Parent.MouseClick:connect(function() for i,v in pairs(Recipes) do HasIngredients = true for i2,v2 in pairs(v[1]) do if not Workspace:FindFirstChild(v2) then HasIngredients = false end end if HasIngredients then for i2,v2 in pairs(v[1]) do Workspace[v2]:Destroy() end print(v[2]) end end end)
|
|
|
| Report Abuse |
|
|
|
| 22 Jun 2014 07:59 AM |
| Is there any other way to do this without the tables and stuff? |
|
|
| Report Abuse |
|
|