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

I made a script for my game, but the script isnt working. Can you fix it?

So I have been working on a map changer. For some reason, the script wont load the map. Please help me. Also since I'm using a desktop, I've been experiencing problems on this site. Ads popped up by google covering up the ask question button. I had to use inspect element. Hint: i put the map changer script in server storage in the maps folder

while true do
	local msg1 = Instance.new("Message",game.Workspace)
	msg1.Text = "MAP LOADING: Sword fights on the heights (by shedletsky) Game lasts for 2 minutes." 
	wait(2)
	msg1:Destroy()
	script.Parent.swordFights.Sky.Parent = game.Lighting
	script.Parent.swordFights.["Sword Fights on the Heights"].Parent = game.Workspace
	wait(120)
	game.Workspace.["Sword Fights on the heights"]:Destroy()
	game.Lighting.Sky:Destroy()
	local msg2 = Instance.new("Message",game.Workspace)
	msg2.Text = "MAP LOADING: Doomspire Brickbattle (by roblox) Game lasts for 2 minutes." 
	wait(2)
	msg2:Destroy()
	script.Parent.doomMap.Sky.Parent = game.Lighting
	script.Parent.doomMap.["Doomspire Brickbattle"].Parent = game.Workspace
	wait(120)
	game.Workspace.["Doomspire Brickbattle"]:Destroy()
	game.Lighting.Sky:Destroy()
	local msg3 = Instance.new("Message",game.Workspace)
	msg1.Text = "MAP LOADING: Chaos Canyon (by roblox) Game lasts for 2 minutes." 
	wait(2)
	msg1:Destroy()
	script.Parent.chaosCanyon.Sky.Parent = game.Lighting
	script.Parent.chaosCanyon.["Canyon"].Parent = game.Workspace
	wait(120)
	game.Workspace.["Canyon"]:Destroy()
	game.Lighting.Sky:Destroy()
	local msg4 = Instance.new("Message",game.Workspace)
	msg5.Text = "MAP LOADING: Haunted Mansion (by telamon) Game lasts for 2 minutes." 
	wait(2)
	msg5:Destroy()
	script.Parent.hauntedMansion.Sky.Parent = game.Lighting
	script.Parent.hauntedMansion.["Mansion"].Parent = game.Workspace
	wait(120)
	game.Workspace.["Mansion"]:Destroy()
	game.Lighting.Sky:Destroy()
	wait()
	end

Please help.

1 answer

✓ Accepted answer

Well their are a few problems with this script one of them being that you cant use .[] like this

 game.Workspace.["Mansion"]:Destroy()

you gotta delete the . before the [ to make it work

Another problem with this script is the undeclared msg5, I'm going to leave that in my script because I believe that u have declared that on another part of the script if not then delete msg5.

Solution:

while true do
	local msg1 = Instance.new("Message",game.Workspace)
	msg1.Text = "MAP LOADING: Sword fights on the heights (by shedletsky) Game lasts for 2 minutes." 
	wait(2)
	msg1:Destroy()
	script.Parent.swordFights.Sky.Parent = game.Lighting
	script.Parent.swordFights["Sword Fights on the Heights"].Parent = game.Workspace
	wait(120)
	game.Workspace["Sword Fights on the heights"]:Destroy()
	game.Lighting.Sky:Destroy()
	local msg2 = Instance.new("Message",game.Workspace)
	msg2.Text = "MAP LOADING: Doomspire Brickbattle (by roblox) Game lasts for 2 minutes." 
	wait(2)
	msg2:Destroy()
	script.Parent.doomMap.Sky.Parent = game.Lighting
	script.Parent.doomMap["Doomspire Brickbattle"].Parent = game.Workspace
	wait(120)
	game.Workspace["Doomspire Brickbattle"]:Destroy()
	game.Lighting.Sky:Destroy()
	local msg3 = Instance.new("Message",game.Workspace)
	msg1.Text = "MAP LOADING: Chaos Canyon (by roblox) Game lasts for 2 minutes." 
	wait(2)
	msg1:Destroy()
	script.Parent.chaosCanyon.Sky.Parent = game.Lighting
	script.Parent.chaosCanyon["Canyon"].Parent = game.Workspace
	wait(120)
	game.Workspace["Canyon"]:Destroy()
	game.Lighting.Sky:Destroy()
	local msg4 = Instance.new("Message",game.Workspace)
	msg5.Text = "MAP LOADING: Haunted Mansion (by telamon) Game lasts for 2 minutes."   --UNDECLEARED
	wait(2)
	msg5:Destroy()                                                                      --UNDECLEARED
	script.Parent.hauntedMansion.Sky.Parent = game.Lighting
	script.Parent.hauntedMansion["Mansion"].Parent = game.Workspace
	wait(120)
	game.Workspace["Mansion"]:Destroy()
	game.Lighting.Sky:Destroy()
	wait()
end

4 comments

0

It still does not work. Can you try another method?

0

did you try deleting the undeclared variables?

0

what do you mean undeclared?

0

omg i get it now, im so dumb. thanks for helping!!

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