You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want to figure out why this script suddenly stops working after playing for about 20 minutes -
What is the issue? Include screenshots / videos if possible!
I wanted to make a “crazy elevator” styled game but its set in space,…I watched some yt tutorial and got a script from the toolbox, not always reliable but i modified it and it works perfectly!, the timer works, the randomizer for the maps (floors) work and im not getting any errors, the only problem is (like i said in the title) that after playing for about 20 minutes the entire script suddenly stops functioning and i get this error: " ServerScriptService.Elevator Script:85: attempt to index nil with ‘Clone’ " -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I haven’t found anything like this on the dev forum yet so I tried making a script that refreshes the main script every few seconds by cloning it , deleting the original one and setting the clone’s parent to the original script’s parent. It obviously didn’t work and gave the same results.
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
This is the script located in serverscriptservice with the name :“elevator script”
-- -- Ajedi32 created the script!
-- Vitorrobloxgames edited Script and instructions!
local Particles = game.Workspace.Particles
local Thruster = game.Workspace.MemeSpaceShip1000.Thruster
--
disasters = {"Noobception","AstralShrek","WorldTripWithAdrien","AstroidsAndTacos","OCEANMAN","CHEEMSvsPIGEON","BANANAS","Uhhh","OneThousandBobux","Banland","SwordFightsOnTheHeights","WOOOOOOOHH","MixUp","Mario","SoftcoreParkour","WereCrashingAAAAH","SpaceRacing","DogOfWisdom","Lemon Demon >:)","AverageFan_VS_AverageEnjoyer","Uhhh_2"} -- This is where you list the names models that you want to use for FLOORS.
-- The list must look like this {"001","002",} and so on.
-- Floor names are case-sensitive and all Floor models must be in the lighting
local RandInstance = Random.new()
local chosenmap = script:WaitForChild("ChosenMap")
countdownTime = 20 -- The ammount of time to wait between each Floor.
disasterTime = 60 -- The ammount of time that the Floor will be in the game before it is removed.
countdownMessage = "Next Stop in %s seconds!" -- The message displayed between disasters. %s will be replaced with the number of seconds left.
disasterMessage = "Floor: %s" -- The message displayed when a disaster occurs. %s will be replaced with the disaster name. Set to nil if you do not want a message
-- Unless you know what you are doing, please leave the below code alone.
items = {}
leaderboard = game.ServerScriptService:findFirstChild("datastore") -- Used to work with my BTS leaderboard
local w = game.ServerScriptService:getChildren()
for i=1,#w do
if w[i].Name == "datastore" and w[i]:findFirstChild("running") ~= nil and w[i]:findFirstChild("points") ~= nil then
leaderboard = w[i]
end
end
for i=1,#disasters do
local item = game.ServerStorage.Maps:findFirstChild(disasters[i])
if item ~= nil then
item.Parent = nil
table.insert(items, item)
else
print("Error! ", disasters[i], " was not found!")
end
end
function sethint(text)
local hint = game.Workspace:findFirstChild("hint")
if (hint ~= nil) then
hint.Text = text
else
print("Hint does not exist, creating...")
hint = Instance.new("Hint")
hint.Name = "hint"
hint.Text = text
hint.Parent = game.Workspace
end
--print("Hint set to: ", text)
end
function removeHint()
hint = game.Workspace:findFirstChild("hint")
if (hint ~= nil) then hint:remove() end
end
function countdown(time)
sethint(string.format(countdownMessage, tostring(time)))
while (time > 0) do
wait(1)
time = time - 1
sethint(string.format(countdownMessage, tostring(time)))
end
removeHint()
return true
end
while true do
countdown(countdownTime)
if leaderboard ~= nil and leaderboard:findFirstChild("running") and leaderboard:findFirstChild("points") then -- For use with my BTS leaderboard.
leaderboard.points.Value = 30 --Points after you survive disasters.
leaderboard.running.Value = true
end
function chooseDisaster()
return items[RandInstance:NextInteger(0, #items)]
end
local m = chooseDisaster():Clone() -----**This is the part that errors after 20 minutes**
if disasterMessage ~= nil then
local msg = Instance.new("Message")
msg.Name = "DisasterMsg"
msg.Text = string.format(disasterMessage, m.Name)
msg.Parent = game.Workspace
wait(3)
msg.Parent = nil
end
-------------------------------------------------------------------
m.Parent = game.Workspace.currentmap
m:makeJoints()
game.Workspace.FakeDoor.Transparency = 1
game.Workspace.FakeDoor.CanCollide = false
Particles.az.ParticleEmitter.Enabled = false
Particles.bn.ParticleEmitter.Enabled = false
Particles.cv.ParticleEmitter.Enabled = false
Particles.df.ParticleEmitter.Enabled = false
Particles.gh.ParticleEmitter.Enabled = false
Particles.hj.ParticleEmitter.Enabled = false
Thruster.az.ParticleEmitter.Enabled = false
Thruster.bn.ParticleEmitter.Enabled = false
Thruster.cv.ParticleEmitter.Enabled = false
print("m added")
-------------------------------------------------------------------
wait(disasterTime)
m:remove()
game.Workspace.FakeDoor.Transparency = 0.4
game.Workspace.FakeDoor.CanCollide = true
Particles.az.ParticleEmitter.Enabled = true
Particles.bn.ParticleEmitter.Enabled = true
Particles.cv.ParticleEmitter.Enabled = true
Particles.df.ParticleEmitter.Enabled = true
Particles.gh.ParticleEmitter.Enabled = true
Particles.hj.ParticleEmitter.Enabled = true
Thruster.az.ParticleEmitter.Enabled = true
Thruster.bn.ParticleEmitter.Enabled = true
Thruster.cv.ParticleEmitter.Enabled = true
local Players = game:GetService('Players')
local Targets = Players:GetPlayers() -- Assigning it as a local is faster.
for _, Player in ipairs(Targets) do
local LowerTorso = Player.Character.LowerTorso
LowerTorso.CFrame = game.Workspace.Model2.sm.CFrame
if Player.Character.LowerTorso == nil then
local Torso = Player.Character.Torso
Torso.CFrame = game.Workspace.Model2.sm.CFrame
end
game.StarterPlayer.CharacterWalkSpeed = 16
end
print("m removed")
------------------------------------------------------------------
if leaderboard ~= nil then -- For use with the bts leaderboard.
leaderboard.running.Value = false
end
end
chooseDisaster(disasters, RandInstance:NextInteger(0, #disasters))
Here’s some screenshots of the locations of the script and the folder where the current map is placed in.