(I'm asking so many questions today)
So I have a toaster, and my game is supposed to be very realistic, so When you unplug the toaster you can't power the toaster.
So I have a BoolValue called "Plugged" in the ToasterPug, and when it's pulled, you shouldn't be able to power the toaster again. Well this doesn't work.
What DOES work is inside of the Plug, there is a part of the script that prevents you from pulling the plug when it's already pulled, and that works.
Here's the script to the Plug. (the one that works)
Plugged = script.Parent.Parent:WaitForChild("Plugged").Value
Cord = script.Parent.Parent.Cord
function onClicked(playerWhoClicked)
if Plugged == true then
Plugged = false
script.Parent.CFrame = script.Parent.CFrame * CFrame.new(0, 1, 0)
Cord.CFrame = Cord.CFrame * CFrame.new(0, 1, 0)
script.Parent.Parent.Plugged.Value = false
script.Parent.Sparkles.Enabled = true
wait(0.5)
script.Parent.Sparkles.Enabled = false
workspace.Toaster.Base.Fire.Enabled = false
workspace.Toaster.Base.Smoke.Enabled = false
workspace.Toaster.Base.PointLight.Enabled = false
wait(5)
workspace.Toaster.Heat1.BrickColor = BrickColor.new("Medium stone grey")
workspace.Toaster.Heat2.BrickColor = BrickColor.new("Medium stone grey")
else return
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)
And here's the script inside the Toaster Switch
Plugged = workspace.ToasterCord:WaitForChild("Plugged").Value
function onClicked(playerWhoClicked)
if Plugged == 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")
wait(10)
script.Parent.Parent.Base.Smoke.Enabled = true
wait(12)
script.Parent.Parent.Base.Smoke.Opacity = 0.3
wait(30)
script.Parent.Parent.Base.Smoke.Opacity = 1
wait(10)
script.Parent.Parent.Base.Fire.Enabled = true
script.Parent.Parent.Base.PointLight.Enabled = true
if Plugged == false then return
end
end
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

1 comment
Thank you! I've been learning so much more about Roblox Lua ever since I joined Scripting Helpers!