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

Vary the Action?

Hello, I'm making a holo. I know how do to chat commands, but I am having trouble with the command that takes the maps. The Script below does not work because not all of the maps are present.

elseif message == "!end" then
local End = game.Workspace.Pitgrounds:remove()
local End2 = game.Workspace.Bricktops:remove()

For example, if I did not load Pitgrounds the error would be, "Bricktops is not a valid member of Workspace"

Please Help

1 answer

Try using a for loop to check if the thing in the workspace is the name of any maps you have. Also, use destroy instead of remove. Remove is laggy because it doesn't actually delete the object.

elseif message == "!end" then
for i,v in pairs (game.Workspace:GetChildren()) do
if v.name = "Map1name" or "Map2name" or "Map3nameyougettheidea" then
v:Destroy()

This only works if the map is a model and you list all the names of the maps that can be loaded in line 3.

If it works don't forget to upvote and accept the answer!

1 comment

0

Why did someone downvote this...? Does it not work or...?

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