Hello! I need some assistance with using elseif statements. I am still new to scripting, and my current ‘project practice task’ is having a banana or an apple fall into a cup, creating juice, as well as the button being clicked ‘animate’ going down and back up. The original script I had with the singular fruits falling into the cup went like this;
local function Onclick()
script.Parent.Transparency = 1
game.Workspace.PushedButton.BrickColor = BrickColor.new(“Lime green”)
game.Workspace.Apple.Anchored = false
game.Workspace.Apple.CanCollide = true
game.Workspace.Juice.Transparency = 0
wait (0.5)
script.Parent.Transparency = 0
end
script.Parent.ClickDetector.MouseClick:Connect(Onclick)
The script.Parent had another part underneath it that would become visible once script.Parent would become transparent. This worked, heres a short video of my success. https://gyazo.com/9ff6fbd62dec11a043c54a33d51dff44
I was trying to advance more, and have 2 fruits go into the cup and mix together once inside into a colour (Red + Yellow = Orange)
This was the script, but it doesn’t seem to work. I’ve spent a while trying to mix and match it, but I don’t know how to set it up properly. I’ve tried multiple ideas that have come to mind, but it’s been unsuccesful so far.
When clicking the button to drop the apple:
local function Onclick()
script.Parent.Transparency = 1
game.Workspace.PushedButton.BrickColor = BrickColor.new(“Lime green”)
game.Workspace.Apple.Anchored = false
game.Workspace.Apple.CanCollide = true
game.Workspace.Juice.Transparency = 0
game.Workspace.Juice.BrickColor = BrickColor.new(“Bright Red”)
if game.Workspace.Juice.BrickColor == BrickColor(“New Yeller”) then
game.Workspace.Juice.BrickColor = BrickColor.new(“Neon orange”)
wait (0.5)
script.Parent.Transparency = 0
end
end
script.Parent.ClickDetector.MouseClick:Connect(Onclick)
Second button for the banana to drop:
local function Onclick()
script.Parent.Transparency = 1
game.Workspace.PushedButton.BrickColor = BrickColor.new(“Lime green”)
game.Workspace.Banana.Anchored = false
game.Workspace.Banana.CanCollide = true
game.Workspace.Juice.Transparency = 0
game.Workspace.Juice.BrickColor = BrickColor.new(“New Yeller”)
if game.Workspace.Juice.BrickColor == BrickColor(“Bright Red”) then
game.Workspace.Juice.BrickColor = BrickColor.new(“Neon orange”)
wait (0.5)
script.Parent.Transparency = 0
end
end
script.Parent.ClickDetector.MouseClick:Connect(Onclick)
When the fruits drop into the cup, starting with the apple, it drops in properly, but the brick becomes grey instead, and not Bright red. When I drop the Banana in, it drops in properly, but the brick becomes yellow, and I suspect that it’s because the dropped apple didn’t make the juice Bright red. I’m not sure what I’m doing wrong. When I re-click the Button that should initially drop in the apple, it turns the juice grey, and doing the same action with the button that drops the banana turns the juice Yellow. Here is a video of what it’s doing:
https://gyazo.com/e7ce46b97ad5500539b5c9376f79f243
I appreciate any replies ! If you also have any resources or links to read, or even people to watch, I’d appreciate that too!