local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local debris = game:GetService("Debris")
local objectsFolder = ReplicatedStorage:WaitForChild("Objects")
local spitOutPart = prompt.Parent.Parent:WaitForChild("SpitOut")
local toaster = prompt.Parent
local running = false
local burning = false
local loopThread = nil
local lastUsedPart = nil
local burnStartTime = 8
local explodeDelay = 8
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 spitOne()
local tpl = pickDifferentPart()
if not tpl then return end
lastUsedPart = tpl.Name
code
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
local upForce = burning and 60 or 25
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)
local ding = Instance.new("Sound")
ding.SoundId = "rbxassetid://5129439677"
ding.Volume = 1
ding.PlayOnRemove = true
ding.Parent = spitOutPart
ding:Destroy()
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!"
code
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.Parent = toaster
task.delay(explodeDelay, 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
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()
local t0 = tick()
loopThread = task.spawn(function()
while running do
spitOne()
if not burning and (tick() - t0) >= burnStartTime then
startBurning()
end
task.wait(burning and 0.3 or 1)
end
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
code
running = not running
prompt.ActionText = running and "turn off" or "turn on"
if running then
task.wait(3)
startLoop()
else
if loopThread then task.cancel(loopThread) end
end
end)
Assistant
Sure! I'll rework your script and add some new features or "modes" to make it more dynamic and fun. Here's what I’ll do:
New Features/Modes Added:
Burn Mode: The toaster already has a burning mode, but I'll enhance it with visual effects like smoke particles.
Explode Mode: When the toaster explodes, it will now have an additional shockwave effect.
Eject Mode: A new mode where the toaster ejects objects faster (like a turbo mode).
Customizable Settings: Allow users to adjust settings like the burn time, explode delay, and eject speed via attributes in the ProximityPrompt.
Sound Effects for Each Mode: Add unique sound effects for each mode (burn, explode, eject).
Here’s the updated script:
lua
-- 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 objectsFolder = ReplicatedStorage:WaitForChild("Objects")
local spitOutPart = prompt.Parent.Parent:WaitForChild("SpitOut")
local toaster = prompt.Parent
-- Configurable Attributes (can be adjusted in Studio)
local burnStartTime = prompt:GetAttribute("BurnStartTime") or 8
local explodeDelay = prompt:GetAttribute("ExplodeDelay") or 8
local ejectSpeedMultiplier = prompt:GetAttribute("EjectSpeedMultiplier") or 1.5
local running = false
local burning = false
local ejectMode = false
local loopThread = nil
local lastUsedPart = nil
-- Helper Functions
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 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
-- Adjust velocity based on eject mode
local upForce = burning and 60 or (ejectMode and 40 or 25)
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)
-- Play sound effect
local ding = Instance.new("Sound")
ding.SoundId = "rbxassetid://5129439677"
ding.Volume = 1
ding.PlayOnRemove = true
ding.Parent = spitOutPart
ding:Destroy()
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 startBurning()
burning = true
prompt.ActionText = "too hot!"
-- Burn sound
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()
-- Fire effect
local fire = Instance.new("Fire")
fire.Name = "BurningEffect"
fire.Size = 6
fire.Heat = 10
fire.Parent = toaster
-- Smoke effect
local smoke = Instance.new("Smoke")
smoke.Color = Color3.fromRGB(50, 50, 50)
smoke.Size = 20
smoke.RiseVelocity = 5
smoke.Parent = toaster
task.delay(explodeDelay, function()
-- Explosion
startExploding()
end)
end
local function startExploding()
-- Explosion visuals
local explVis = Instance.new("Explosion")
explVis.Position = toaster.Position
explVis.BlastRadius = 20
explVis.BlastPressure = 500000
explVis.DestroyJointRadiusPercent = 0
explVis.Parent = workspace
-- Explosion sound
local explSound = Instance.new("Sound")
explSound.SoundId = "rbxassetid://5801257793"
explSound.Volume = 1
explSound.Parent = toaster
explSound:Play()
-- Shockwave effect
local shockwave = Instance.new("Part")
shockwave.Shape = Enum.PartType.Ball
shockwave.Size = Vector3.new(1, 1, 1)
shockwave.Anchored = true
shockwave.CanCollide = false
shockwave.Transparency = 0.5
shockwave.Color = Color3.fromRGB(255, 255, 0)
shockwave.CFrame = CFrame.new(toaster.Position)
shockwave.Parent = workspace
for i = 1, 10 do
shockwave.Size = shockwave.Size + Vector3.new(2, 0.1, 2)
task.wait(0.05)
end
shockwave:Destroy()
running = false
burning = false
if loopThread then task.cancel(loopThread) end
prompt.Enabled = false
-- Destroy toaster and room
local model = toaster.Parent
for _, obj in ipairs(model:GetDescendants()) do
if obj:IsA("BasePart") then
obj.Anchored = false
obj:ApplyImpulse(Vector3.new(math.random(-50, 50), math.random(50, 100), math.random(-50, 50)))
end
end
-- Room destruction
local room = workspace:FindFirstChild("room")
if room then
for _, obj in ipairs(room:GetDescendants()) do
if obj:IsA("BasePart") then
obj.Anchored = false
obj:ApplyImpulse(Vector3.new(math.random(-50, 50), math.random(50, 100), math.random(-50, 50)))
end
end
end
end
local function toggleEjectMode()
ejectMode = not ejectMode
if ejectMode then
prompt.ActionText = "turbo mode!"
else
prompt.ActionText = "turn off"
end
end
local function startLoop()
local t0 = tick()
loopThread = task.spawn(function()
while running do
spitOne()
if not burning and (tick() - t0) >= burnStartTime then
startBurning()
end
task.wait(burning and 0.3 or 1)
end
end)
end
prompt.Triggered:Connect(function()
if burning then
-- Click sound when burning
local clickS = Instance.new("Sound")
clickS.SoundId = "rbxassetid://9066167010"
clickS.Volume = 1
clickS.Parent = toaster
clickS:Play()
debris:AddItem(clickS, 3)
return
end
if ejectMode then
toggleEjectMode()
return
end
running = not running
if running then
prompt.ActionText = "turn off"
task.wait(3)
startLoop()
else
prompt.ActionText = "turn on"
if loopThread then task.cancel(loopThread) end
end
end)
-- Double-click to toggle eject mode
local lastTriggerTime = 0
prompt.Triggered:Connect(function(player)
local currentTime = tick()
if currentTime - lastTriggerTime < 0.5 then
toggleEjectMode()
end
lastTriggerTime = currentTime
end)
Key Changes:
Eject Mode: Double-click the ProximityPrompt to toggle turbo eject mode.
Shockwave Effect: Added a shockwave during the explosion.
Smoke Particles: Added smoke particles during the burn phase.
Customizable Attributes: You can now adjust settings like BurnStartTime, ExplodeDelay, and EjectSpeedMultiplier directly in Studio.