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

Okay so I have a script that wont destroy the Part "Game". Can anyone help me?

local soundregions = workspace:FindFirstChild("SoundRegions")
if game.Workspace:FindFirstChild("Bridge Fight: By ReaIisticaI") then
script.Parent.Parent = soundregions
end

local Map = game.Workspace:FindFirstChild("Bridge Fight: By ReaIisticaI")
local Game = workspace.SoundRegions:FindFirstChild("Game")
if Game and not Map then
	Game:Destroy()
end

2 answers

I think it's because Game is another variable for the global roblox variable game, so the Game variable is overwriting the variable that you made. Try renaming the variable that you made to something like gameSoundRegion or something like that.

Because of the capitalized letter, the fact that game is a global roblox term shouldn't matter in this case. Have you checked to see if it's because of the not Map check? You can use this code to determine if it is, replacing it with lines 8-10:

if Game then
	print("Game works fine")
elseif not Map then
	print("not Map works fine")
end

if both of these print into your output (which you can enable on View tab of Studio), the problem may be that the Game part is not in SoundRegions

2 comments

0

Game and game will both return the DataModel

0

Well one thing is that when the game starts the Game part is not in SoundRegions once the part game is moved then it will be in sound regions and then I want it to be destroyed

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