Here's a reworked version of your toaster script with several new features and modes:
-- Enhanced Toaster Script with Multiple Modes
-- Put this Script inside the ProximityPrompt
local prompt = script.Parent
prompt.ObjectText = "toaster"
prompt.ActionText = "turn on"
prompt.MaxActivationDistance = 10
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local debris = game:GetService("Debris")
local TweenService = game:GetService("TweenService")
local objectsFolder = ReplicatedStorage:WaitForChild("Objects")
local spitOutPart = prompt.Parent.Parent:WaitForChild("SpitOut")
local toaster = prompt.Parent
-- State variables
local running = false
local burning = false
local loopThread = nil
local lastUsedPart = nil
local currentMode = 1
local temperature = 0
local maxTemperature = 100
local itemsLaunched = 0
-- Mode configurations
local modes = {
{
name = "Normal",
color = Color3.fromRGB(255, 176, 0),
launchDelay = 1,
launchForce = 25,
tempIncrease = 5,
burnThreshold = 80,
description = "Standard toasting mode"
},
{
name = "Turbo",
color = Color3.fromRGB(255, 0, 0),
launchDelay = 0.3,
launchForce = 40,
tempIncrease = 10,
burnThreshold = 60,
description = "Fast & furious toasting!"
},
{
name = "Gentle",
color = Color3.fromRGB(135, 206, 235),
launchDelay = 2,
launchForce = 15,
tempIncrease = 2,
burnThreshold = 95,
description = "Slow and steady"
},
{
name = "Party",
color = Color3.fromRGB(255, 0, 255),
launchDelay = 0.5,
launchForce = 30,
tempIncrease = 7,
burnThreshold = 70,
description = "Rainbow party mode!",
special = "rainbow"
},
{
name = "Frozen",
color = Color3.fromRGB(173, 216, 230),
launchDelay = 1.5,
launchForce = 20,
tempIncrease = -3, -- Actually cools down!
burnThreshold = 100,
description = "Ice cold toasting",
special = "frozen"
}
}
-- Create UI for mode display
local function createUI()
local billboardGui = Instance.new("BillboardGui")
billboardGui.Name = "ToasterUI"
billboardGui.Size = UDim2.new(4, 0, 2, 0)
billboardGui.StudsOffset = Vector3.new(0, 3, 0)
billboardGui.Parent = toaster
local frame = Instance.new("Frame")
frame.Size = UDim2.new(1, 0, 1, 0)
frame.BackgroundTransparency = 0.3
frame.BackgroundColor3 = Color3.new(0, 0, 0)
frame.BorderSizePixel = 0
frame.Parent = billboardGui
local modeLabel = Instance.new("TextLabel")
modeLabel.Name = "ModeLabel"
modeLabel.Size = UDim2.new(1, 0, 0.4, 0)
modeLabel.BackgroundTransparency = 1
modeLabel.Text = "Mode: " .. modes[currentMode].name
modeLabel.TextScaled = true
modeLabel.TextColor3 = modes[currentMode].color
modeLabel.Font = Enum.Font.SourceSansBold
modeLabel.Parent = frame
local tempBar = Instance.new("Frame")
tempBar.Name = "TempBar"
tempBar.Size = UDim2.new(0.8, 0, 0.2, 0)
tempBar.Position = UDim2.new(0.1, 0, 0.5, 0)
tempBar.BackgroundColor3 = Color3.new(0.2, 0.2, 0.2)
tempBar.BorderSizePixel = 0
tempBar.Parent = frame
local tempFill = Instance.new("Frame")
tempFill.Name = "TempFill"
tempFill.Size = UDim2.new(0, 0, 1, 0)
tempFill.BackgroundColor3 = Color3.fromRGB(255, 100, 0)
tempFill.BorderSizePixel = 0
tempFill.Parent = tempBar
local statsLabel = Instance.new("TextLabel")
statsLabel.Name = "StatsLabel"
statsLabel.Size = UDim2.new(1, 0, 0.2, 0)
statsLabel.Position = UDim2.new(0, 0, 0.8, 0)
statsLabel.BackgroundTransparency = 1
statsLabel.Text = "Items: 0"
statsLabel.TextScaled = true
statsLabel.TextColor3 = Color3.new(1, 1, 1)
statsLabel.Font = Enum.Font.SourceSans
statsLabel.Parent = frame
return billboardGui
end
local ui = createUI()
-- Helper functions
local function updateUI()
local modeLabel = ui.Frame.ModeLabel
local tempFill = ui.Frame.TempBar.TempFill
local statsLabel = ui.Frame.StatsLabel
modeLabel.Text = "Mode: " .. modes[currentMode].name
modeLabel.TextColor3 = modes[currentMode].color
-- Update temperature bar
local tempPercent = math.clamp(temperature / maxTemperature, 0, 1)
tempFill.Size = UDim2.new(tempPercent, 0, 1, 0)
-- Color temperature bar based on heat
if temperature < 30 then
tempFill.BackgroundColor3 = Color3.fromRGB(0, 255, 0)
elseif temperature < 60 then
tempFill.BackgroundColor3 = Color3.fromRGB(255, 255, 0)
else
tempFill.BackgroundColor3 = Color3.fromRGB(255, 0, 0)
end
statsLabel.Text = "Items: " .. itemsLaunched .. " | Temp: " .. math.floor(temperature) .. "°"
end
local function fadeOut(part)
local t0, fadeTime, origT = tick(), 5, part.Transparency
local conn
conn = RunService.Heartbeat:Connect(function()
local dt = tick() - t0
if dt < fadeTime then
part.Transparency = origT + (dt / fadeTime)
else
conn:Disconnect()
part:Destroy()
end
end)
end
local function pickDifferentPart()
local kids = objectsFolder:GetChildren()
if #kids == 0 then return nil end
for _ = 1, 5 do
local c = kids[math.random(#kids)]
if c.Name ~= lastUsedPart then
return c
end
end
return kids[math.random(#kids)]
end
local function applySpecialEffects(clone, mode)
if mode.special == "rainbow" then
-- Rainbow effect
task.spawn(function()
local hue = 0
while clone and clone.Parent do
hue = (hue + 2) % 360
local color = Color3.fromHSV(hue/360, 1, 1)
if clone:IsA("Model") then
for _, part in ipairs(clone:GetDescendants()) do
if part:IsA("BasePart") then
part.Color = color
end
end
elseif clone:IsA("BasePart") then
clone.Color = color
end
task.wait(0.1)
end
end)
elseif mode.special == "frozen" then
-- Frozen effect
if clone:IsA("Model") then
for _, part in ipairs(clone:GetDescendants()) do
if part:IsA("BasePart") then
part.Material = Enum.Material.Ice
part.Color = Color3.fromRGB(173, 216, 230)
end
end
elseif clone:IsA("BasePart") then
clone.Material = Enum.Material.Ice
clone.Color = Color3.fromRGB(173, 216, 230)
end
end
end
local function spitOne()
local tpl = pickDifferentPart()
if not tpl then return end
lastUsedPart = tpl.Name
local clone = tpl:Clone()
clone.Anchored = false
clone.CanCollide = true
clone.Parent = workspace
local launchPart
if clone:IsA("Model") then
if not clone.PrimaryPart then
warn("Model lacks PrimaryPart:", clone.Name)
clone:Destroy()
return
end
clone:SetPrimaryPartCFrame(spitOutPart.CFrame)
launchPart = clone.PrimaryPart
elseif clone:IsA("BasePart") then
clone.CFrame = spitOutPart.CFrame
launchPart = clone
else
warn("Unsupported object:", clone.ClassName)
clone:Destroy()
return
end
-- Apply special effects based on mode
applySpecialEffects(clone, modes[currentMode])
local upForce = burning and 60 or modes[currentMode].launchForce
local vel = Vector3.new(math.random(-5,5), upForce, math.random(-5,5))
local bv = Instance.new("BodyVelocity")
bv.Velocity = vel
bv.MaxForce = Vector3.new(1e5,1e5,1e5)
bv.P = 1e4
bv.Parent = launchPart
debris:AddItem(bv, 0.3)
-- Different sounds for different modes
local ding = Instance.new("Sound")
if currentMode == 4 then -- Party mode
ding.SoundId = "rbxassetid://1837829261" -- Party horn sound
ding.Pitch = math.random(8, 12) / 10
elseif currentMode == 5 then -- Frozen mode
ding.SoundId = "rbxassetid://265970978" -- Ice sound
else
ding.SoundId = "rbxassetid://5129439677"
end
ding.Volume = 0.5
ding.PlayOnRemove = true
ding.Parent = spitOutPart
ding:Destroy()
itemsLaunched = itemsLaunched + 1
updateUI()
task.delay(0.5, function()
if clone:IsA("Model") then
for _, d in ipairs(clone:GetDescendants()) do
if d:IsA("BasePart") then fadeOut(d) end
end
else
fadeOut(clone)
end
end)
end
local function removeWeldsFrom(partOrModel)
for _, d in ipairs(partOrModel:GetDescendants()) do
if d:IsA("Weld") or d:IsA("WeldConstraint") or d:IsA("Motor6D") then
d:Destroy()
end
end
end
local function flingPart(part)
local bv = Instance.new("BodyVelocity")
bv.Velocity = Vector3.new(math.random(-8,8), math.random(12,18), math.random(-8,8))
bv.MaxForce = Vector3.new(1e5,1e5,1e5)
bv.P = 1e4
bv.Parent = part
debris:AddItem(bv, 0.4)
end
local function startBurning()
burning = true
prompt.ActionText = "too hot!"
local burnS = Instance.new("Sound")
burnS.Name = "BurnSound"
burnS.SoundId = "rbxassetid://158853971"
burnS.Looped = true
burnS.Volume = 1
burnS.RollOffMode = Enum.RollOffMode.Linear
burnS.RollOffMinDistance = 10
burnS.RollOffMaxDistance = 30
burnS.Parent = toaster
burnS:Play()
local fire = Instance.new("Fire")
fire.Name = "BurningEffect"
fire.Size = 6
fire.Heat = 10
fire.Color = modes[currentMode].color
fire.SecondaryColor = Color3.new(1, 0, 0)
fire.Parent = toaster
task.delay(8, function()
-- Explosion
local explVis = Instance.new("Explosion")
explVis.Position = toaster.Position
explVis.BlastRadius = 20
explVis.BlastPressure = 500000
explVis.DestroyJointRadiusPercent = 0
explVis.Parent = workspace
local explSound = Instance.new("Sound")
explSound.SoundId = "rbxassetid://5801257793"
explSound.Volume = 1
explSound.Parent = toaster
explSound:Play()
running = false
burning = false
temperature = 0
if loopThread then task.cancel(loopThread) end
prompt.Enabled = false
local model = toaster.Parent
removeWeldsFrom(model)
for _, obj in ipairs(model:GetDescendants()) do
if obj:IsA("BasePart") then
obj.Anchored = false
flingPart(obj)
task.delay(0.15, function()
flingPart(obj)
end)
local smallFire = Instance.new("Fire")
smallFire.Size = 4
smallFire.Heat = 5
smallFire.Parent = obj
end
end
-- Room explosion
local room = workspace:FindFirstChild("room")
if room then
removeWeldsFrom(room)
for _, obj in ipairs(room:GetDescendants()) do
if obj:IsA("BasePart") then
obj.Anchored = false
flingPart(obj)
task.delay(0.15, function()
flingPart(obj)
end)
end
end
end
end)
end
local function startLoop()
loopThread = task.spawn(function()
while running do
spitOne()
-- Update temperature
temperature = math.clamp(temperature + modes[currentMode].tempIncrease, 0, maxTemperature)
updateUI()
-- Check for burning
if not burning and temperature >= modes[currentMode].burnThreshold then
startBurning()
end
task.wait(burning and 0.3 or modes[currentMode].launchDelay)
end
end)
end
-- Mode switching
toaster.ClickDetector = toaster:FindFirstChild("ClickDetector") or Instance.new("ClickDetector", toaster)
toaster.ClickDetector.MaxActivationDistance = 10
toaster.ClickDetector.MouseClick:Connect(function()
if not burning and not running then
currentMode = (currentMode % #modes) + 1
updateUI()
-- Mode change sound
local changeSound = Instance.new("Sound")
changeSound.SoundId = "rbxassetid://421058925"
changeSound.Volume = 0.5
changeSound.Pitch = 0.8 + (currentMode * 0.1)
changeSound.Parent = toaster
changeSound:Play()
debris:AddItem(changeSound, 2)
-- Visual effect
local flash = Instance.new("PointLight")
flash.Brightness = 3
flash.Color = modes[currentMode].color
flash.Range = 10
flash.Parent = toaster
TweenService:Create(flash, TweenInfo.new(0.5), {Brightness = 0}):Play()
debris:AddItem(flash, 0.5)
prompt.HoldDuration = 0
prompt.ActionText = "Mode: " .. modes[currentMode].name
task.wait(2)
prompt.ActionText = running and "turn off" or "turn on"
end
end)
-- Temperature cooldown when not running
task.spawn(function()
while toaster.Parent do
if not running and temperature > 0 then
temperature = math.max(0, temperature - 1)
updateUI()
end
task.wait(0.5)
end
end)
prompt.Triggered:Connect(function()
if burning then
local clickS = Instance.new("Sound")
clickS.SoundId = "rbxassetid://9066167010"
clickS.Volume = 1
clickS.Parent = toaster
clickS:Play()
debris:AddItem(clickS, 3)
return
end
running = not running
prompt.ActionText = running and "turn off" or "turn on"
if running then
-- Startup sound
local startSound = Instance.new("Sound")
startSound.SoundId = "rbxassetid://268249319"
startSound.Volume = 0.5
startSound.Parent = toaster
startSound:Play()
debris:AddItem(startSound, 3)
task.wait(3)
startLoop()
else
if loopThread then task.cancel(loopThread) end
-- Shutdown sound
local stopSound = Instance.new("Sound")
stopSound.SoundId = "rbxassetid://268249339"
stopSound.Volume = 0.5
stopSound.Parent = toaster
stopSound:Play()
debris:AddItem(stopSound, 3)
end
end)