Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 4 years ago
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

Log in to vote
1
Answered by 4 years ago

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.

Ad
Log in to vote
0
Answered by
Avoxea 48
4 years ago
Edited 4 years ago

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

0
Game and game will both return the DataModel thatwalmartman 404 — 4y
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 Nistrict 44 — 4y

Answer this question