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

anyone got any easier way to do pick what map to spawn?

hello scripting helpers! i just wanna know if theres an easier way to pick what map to spawn. thats about it

script.Parent.MouseClick:Connect(function()
	print("button pressed")
	local Room = math.random(1,2)
	if Room == 1 then
		local map = game.ReplicatedStorage.TestMaps.Map1:Clone()
		print("cloned")
		map.Parent = game.Workspace
		print("parent changed")
	map:MoveTo(script.Parent.Parent.Parent.EndPoint.Position - Vector3.new(0,0,1))
		wait(0.1)
		end
	if Room == 2 then
		local map = game.ReplicatedStorage.TestMaps.Map2:Clone()
		print("cloned")
		map.Parent = game.Workspace
		print("parent changed")
		map:MoveTo(script.Parent.Parent.Parent.EndPoint.Position - Vector3.new(0,0,1))
		wait(0.1)
	end
	script.Parent.Parent:Destroy()
end)

any help would be nice :)

1 answer

nvm i got it.

script.Parent.MouseClick:Connect(function()
	local Kids = game.ReplicatedStorage.TestMaps:GetChildren()
	
	local Ran = math.random(1,#Kids)
	
	local Fartz = Kids[Ran]
	
	local map = Fartz:Clone()
	print("cloned")
	map.Parent = game.Workspace
	print("parent changed")
	map:MoveTo(script.Parent.Parent.Parent.EndPoint.Position - Vector3.new(0,0,1))
end)

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