Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Problem with if-then-elseif Statement?

(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

3 comments

0

Did you not take my advice from before?

1

Do you have a ClickDetector object, with a connect method running through it?

0

Oh, that explains it. I failed. While I was editing it I removed the connecting statement. Thank you for that reminder.

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.