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

Map loader GUI's button won't delete a map when told to?

So I want to make a map loader GUI, and when a ImageButton is pressed, it will check if there's already a map in a folder and if there is, delete it.

Here's my code:

script.Parent.MouseButton1Click:Connect(function(click)
	if game.Teams:FindFirstChildOfClass("Model") == true then -- This is the part that doesnt work
		game.Teams:ClearAllChildren()
	else
		game.ServerStorage.SMG:Clone()
	    game.ServerStorage.SMG.Parent = game.Teams.Red
	    game.ServerStorage.SMG:Clone()
	    game.ServerStorage.SMG.Parent = game.Teams.Red
	end
end)

1 answer

try this:

script.Parent.MouseButton1Click:Connect(function(click)
    if game.Teams:FindFirstChildOfClass("Model") then -- This might work
        game.Teams:ClearAllChildren()
    else
        game.ServerStorage.SMG:Clone()
        game.ServerStorage.SMG.Parent = game.Teams.Red
        game.ServerStorage.SMG:Clone()
        game.ServerStorage.SMG.Parent = game.Teams.Red
    end
end)

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