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

Vary the Action?

Asked by
PixelYT 30
9 years ago

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

Log in to vote
0
Answered by
yoshiegg6 176
9 years ago

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!

0
Why did someone downvote this...? Does it not work or...? yoshiegg6 176 — 9y
Ad

Answer this question