Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Problem with if-then-elseif Statement?

Asked by 10 years ago

(so many Toaster issues - sigh)

So the last thing I added was damage, so it's either that or the help I got in my previous question that broke this script

The problem is the script doesn't run when I click it. There are no errors, so I'm guessing that it has something to do with the plugged in or not statement.

Here's the (hopefully) final script that doesn't work:

Plugged = workspace.ToasterCord:WaitForChild("Plugged")
Damage = script.Parent.Parent.Hurt.Damage

function onClicked(playerWhoClicked)
   if Plugged.Value == true then
    script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, -0.4, 0)
    wait(0.7)
    script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 0.4, 0)
    wait(6)
    workspace.Toaster.Heat1.BrickColor = BrickColor.new("Dusty Rose")
    workspace.Toaster.Heat2.BrickColor = BrickColor.new("Dusty Rose")
    wait(6)
    workspace.Toaster.Heat1.BrickColor = BrickColor.Red()
    workspace.Toaster.Heat2.BrickColor = BrickColor.Red()
    wait(8)
    workspace.Toaster.Heat1.BrickColor = BrickColor.new("Really red")
    workspace.Toaster.Heat2.BrickColor = BrickColor.new("Really red")
    Damage.Value = 1
    wait(10)
    script.Parent.Parent.Base.Smoke.Enabled = true
    Damage.Value = 2
    wait(12)
    script.Parent.Parent.Base.Smoke.Opacity = 0.3
    Damage.Value = 3
    wait(30)
    script.Parent.Parent.Base.Smoke.Opacity = 1
    Damage. Value = 7
    wait(10)
    script.Parent.Parent.Base.Fire.Enabled = true
    script.Parent.Parent.Base.PointLight.Enabled = true
    Damage.Value = 14
elseif Plugged.Value == false then
    return
end
end
0
Did you not take my advice from before? RedCombee 585 — 10y
1
Do you have a ClickDetector object, with a connect method running through it? Redbullusa 1580 — 10y
0
Oh, that explains it. I failed. While I was editing it I removed the connecting statement. Thank you for that reminder. SpazzMan502 133 — 10y

1 answer

Log in to vote
0
Answered by 10 years ago

You need to call the function. I am assuming that this is a part you have a ClickDetector in it. At line 37 put:

script.Parent.MouseButton1Click:connect(onClicked)
Ad

Answer this question