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

Help With :Destroy()?

I have a script where my game cycles through three phases, the lobby phase, loading phase, and the game phase.

However at the end of the game phase, the bricks that have been cloned in are not being destroyed, and there are no errors.

Here is my code (btw the lt, l2t, and gt are intvalues representing the amount of time left in a specific phase):

--{{VARIABLES}}--
g = game.Workspace.gameRunner.inGame
s = g.Parent.status
gt = game.Workspace.gameRunner.gameTime
lt = game.Workspace.gameRunner.lobbyTime
l2t = game.Workspace.gameRunner.loadTime
--{{CHECKER}}--
while true do
	if l2t.Value == 15 then
		wait(1)
		game.ServerStorage.Fallen:MakeJoints()
		game.ServerStorage.Fallen:Clone().Parent = game.Workspace
		game.Workspace.Fallen.Name = "fallenCopy"
	elseif gt == 1 then
			game.Workspace.fallenCopy:Destroy()
	end
	wait(1)
end

Here is another idea for a solution which also did not work:

--{{VARIABLES}}--
g = game.Workspace.gameRunner.inGame
s = g.Parent.status
gt = game.Workspace.gameRunner.gameTime
lt = game.Workspace.gameRunner.lobbyTime
l2t = game.Workspace.gameRunner.loadTime
--{{CHECKER}}--
while true do
	if l2t.Value == 15 then
		wait(1)
		game.ServerStorage.Fallen:MakeJoints()
		game.ServerStorage.Fallen:Clone().Parent = game.Workspace
		game.Workspace.Fallen.Name = "fallenCopy"
		end
		if gt == 1 then
			game.Workspace.fallenCopy:Destroy()
	end
	wait(1)
end

A solution would be highly appreciated as I have been stumped on this for a while!

2 comments

0

I would assume it isn't working because of your "elseif." Unless you already have something in the workspace named "fallenCopy," it will have nothing to Destroy because l2t's value isn't 15, therefore it didn't clone the object/s.

0

I changed it around to this and it didn't work. Any ideas?:

1 answer

✓ Accepted answer

Got it!! there was just a few mistakes i labeled them for you!!

--{{VARIABLES}}--
	g = game.Workspace.gameRunner.inGame
	gt = game.Workspace.gameRunner.gameTime
	lt = game.Workspace.gameRunner.lobbyTime
	l2t = game.Workspace.gameRunner.loadTime
	--{{CHECKER}}--
	while true do
		wait(1)
	    if l2t.Value >= 15 then -- i recommened always using >= 
								--because at the odd chance that your game skips a count. 
								--your script will crash
		l2t.Value = 0 -- this was causing an over copy remove if ya want
		game.ServerStorage.Fallen:MakeJoints()
		a = game.ServerStorage.Fallen:Clone()-- i prefer declaring it as a variable 
		a.Parent = game.Workspace
	    a.Name = "fallenCopy"  -- The script was never naming the Model FallenCopy :'(


        end
	    if gt.Value == 1 then -- You forgot to add .Value :)
	    game.Workspace.fallenCopy:Destroy()
	    end
	    wait(1)
	end

1 comment

0

I used this, and then modified it a bit. Thank you!

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