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

Problem with regenerating a section?

im working on a "tower of hell" styled game and when the timer runs out the section does not regen it does work when generating the section of the tower but it won't regen when the timer runs out.

local clonedmap -- the variable

game.ReplicatedStorage.ResetEvent.OnServerEvent:Connect(function() -- checking if the event has been fired
	local Section = math.random(1,3)
	
	if clonedmap then -- these 3 lines don't work
		clonedmap:Destroy()
	end
	
	if Section == 1 then -- randomizing the map no problems with this
		local map = game.ReplicatedStorage.Upwards
		clonedmap = map:Clone()
		clonedmap.Parent = workspace
		clonedmap:SetPrimaryPartCFrame(script.Parent.CFrame)
	elseif Section == 2 then
		local map = game.ReplicatedStorage.Bonjour
		clonedmap = map:Clone()
		clonedmap.Parent = workspace
		clonedmap:SetPrimaryPartCFrame(script.Parent.CFrame)
	elseif Section == 3 then
		local map = game.ReplicatedStorage.Spinners
		clonedmap = map:Clone()
		clonedmap.Parent = workspace
		clonedmap:SetPrimaryPartCFrame(script.Parent.CFrame)
	end
end)	

also have no console errors

2 comments

0

so, where is the code for the timer?

0

its splitted into multiple scripts i can post them

1 answer

local plr = game.Players.LocalPlayer
game.ReplicatedStorage.ResetEvent:FireServer(plr) -- startup for the spawner and timer
while wait() and workspace.Time.Value <= 0 do
	game.ReplicatedStorage.ResetEvent:FireServer(plr)
end

3 comments

0

correction no only one

0

wait no

0

workspace.Time.Changed:Connect(function() if workspace.Time.Value <= 0 then workspace.Time.Value = 300 end end)

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